->Fixed a bug where arrows would not properly disappear when hitting
mobs. ->Fixed a bug where mobs could not deal damage to each other. ->Removed mob spawn height reductions for worlds that are not the Overworld. ->Added a new non-deprecated version of DealDamageToEntity(). ->Updated Striker Mode, Defender Mode, and Ranger Mode descriptions in-game. ->Mobs are smarter about where they spawn now. They will figure out areas that are dangerous and avoid them. You can check what the expected Habitation level of an area is with /stats.
This commit is contained in:
parent
7187c1414a
commit
df10def718
Binary file not shown.
@ -1,6 +1,6 @@
|
||||
name: TwosideKeeper
|
||||
main: sig.plugin.TwosideKeeper.TwosideKeeper
|
||||
version: 3.7.1r1
|
||||
version: 3.7.2
|
||||
commands:
|
||||
money:
|
||||
description: Tells the player the amount of money they are holding.
|
||||
|
@ -1952,6 +1952,8 @@ public class GenericFunctions {
|
||||
+ ChatColor.GRAY+"->Getting hit as a defender increases saturation.\n"
|
||||
+ ChatColor.WHITE+"->Hitting mobs as a Defender aggros them to you.\n"
|
||||
+ ChatColor.GRAY+"->Knockback from attacks reduced by 75% while blocking.\n"
|
||||
+ ChatColor.WHITE+"- "+ChatColor.BOLD+"Rejuvenation"+ChatColor.RESET+ChatColor.WHITE+"\n"
|
||||
+ ChatColor.GRAY+"->Knockback from attacks reduced by 75% while blocking.\n"
|
||||
;
|
||||
}
|
||||
case "striker":{
|
||||
@ -1962,26 +1964,27 @@ public class GenericFunctions {
|
||||
+ ChatColor.GRAY+"->Every 10% of missing health increases your damage by 10%. (Ex. 99% damage increase at 99% lost hp.)\n"
|
||||
+ ChatColor.WHITE+"->Getting hit increases Speed by 1 Level. Stacks up to Speed V (Lasts five seconds.)\n"
|
||||
+ ChatColor.GRAY+"->Swinging your weapon stops nearby flying arrows. Each arrow deflected will give you a Strength buff. Stacks up to Strength V (Lasts five seconds.)\n"
|
||||
+ ChatColor.WHITE+"->Throwing your weapon while sneaking will perform a line drive. Enemies you charge through take x7 your base damage. This costs 5% of your durability (Unbreaking decreases this amount.)\n"
|
||||
+ ChatColor.WHITE+"->Throwing your weapon will perform a line drive. Enemies you charge through take x7 your base damage. This costs 5% of your durability (Unbreaking decreases this amount.)\n"
|
||||
+ ChatColor.GRAY+"->Strikers have a 20% chance to dodge incoming attacks from any damage source while moving.\n"
|
||||
+ ChatColor.WHITE+"->Hitting a target when both the player and the enemy are at full health deals x3 normal damage.\n"
|
||||
;
|
||||
}
|
||||
case "ranger":{
|
||||
return ChatColor.DARK_GREEN+""+ChatColor.BOLD+mode+" mode Perks: "+ChatColor.RESET+"\n"
|
||||
+ ChatColor.WHITE+"->Players are identified as 'Rangers' when they only carry a bow in their main hand. No off-hand items except for an arrow quiver. Can only be wearing leather armor, or no armor.\n"
|
||||
+ ChatColor.WHITE+"->Players are identified as 'Rangers' when they carry a bow in their main hand. Off-hand items are permitted, except for a shield. Can only be wearing leather armor, or no armor.\n"
|
||||
+ ChatColor.GRAY+"->Left-clicking mobs will cause them to be knocked back extremely far, basically in headshot range, when walls permit.\n"
|
||||
+ ChatColor.WHITE+"->Base Arrow Damage increases from x1->x4.\n"
|
||||
+ ChatColor.GRAY+"->Arrow speed massively increases. Your old max firing speed is the new minimum drawback speed.\n"
|
||||
+ ChatColor.WHITE+"->You can dodge 50% of all incoming attacks from any damage sources.\n"
|
||||
+ ChatColor.GRAY+"You have immunity to all Thorns damage.\n"
|
||||
+ ChatColor.WHITE+"Shift-Left Click to change Bow Modes.\n"
|
||||
+ ChatColor.GRAY+"- Close Range Mode (Default): \n"
|
||||
+ ChatColor.WHITE+" You gain the ability to deal headshots from any distance, even directly onto an enemy's face. Each kill made in this mode gives you 100% dodge chance for the next hit taken. You can tumble and gain invulnerability for 1 second by pressing shift + left-click.\n"
|
||||
+ ChatColor.GRAY+"- Sniping Mode: \n"
|
||||
+ ChatColor.WHITE+" Headshot collision area increases by x3. Headshots will deal an extra x0.25 damage for each headshot landed, up to a cap of 8 stacks. Each stack also increases your Slowness level by 1.\n"
|
||||
+ ChatColor.GRAY+"- Debilitation Mode:\n"
|
||||
+ ChatColor.WHITE+"->Base Arrow Damage increases from x1->x2.\n"
|
||||
+ ChatColor.GRAY+"->You can dodge 50% of all incoming attacks from any damage sources.\n"
|
||||
+ ChatColor.WHITE+"You have immunity to all Thorns damage.\n"
|
||||
+ ChatColor.GRAY+"Shift-Right Click to change Bow Modes.\n"
|
||||
+ ChatColor.WHITE+"- "+ChatColor.BOLD+"Close Range Mode (Default):"+ChatColor.RESET+ChatColor.WHITE+" \n"
|
||||
+ ChatColor.GRAY+" You gain the ability to deal headshots from any distance, even directly onto an enemy's face. Each kill made in this mode gives you 100% dodge chance for the next hit taken. You can tumble and gain invulnerability for 1 second by pressing shift + left-click.\n"
|
||||
+ ChatColor.WHITE+"- "+ChatColor.BOLD+"Sniping Mode:"+ChatColor.RESET+ChatColor.WHITE+" \n"
|
||||
+ ChatColor.GRAY+" Headshot collision area increases by x3. Headshots will deal an extra x0.25 damage for each headshot landed, up to a cap of 8 stacks. Each stack also increases your Slowness level by 1.\n"
|
||||
+ ChatColor.WHITE+" Arrows are lightning-fast in Sniping Mode.\n"
|
||||
+ ChatColor.GRAY+"- "+ChatColor.BOLD+"Debilitation Mode:"+ChatColor.RESET+ChatColor.WHITE+" \n"
|
||||
+ ChatColor.WHITE+" Adds a stack of Poison when hitting non-poisoned targets (20 second duration). Hitting mobs in this mode refreshes the duration of the poison stacks. Headshots made in this mode will increase the level of Poison on the mob, making the mob more and more vulnerable.\n"
|
||||
+ ChatColor.GRAY+" Headshots also remove one level of a buff (does not affect debuffs) applied to the mob at random.\n"
|
||||
;
|
||||
}
|
||||
default:{
|
||||
@ -2546,6 +2549,12 @@ public class GenericFunctions {
|
||||
DealDamageToMob(dmg,target,damager);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void DealDamageToMob(double dmg, LivingEntity target, Entity damager) {
|
||||
DealDamageToMob(dmg,target,NewCombat.getDamagerEntity(damager));
|
||||
}
|
||||
|
||||
public static void DealDamageToMob(double dmg, LivingEntity target, LivingEntity damager) {
|
||||
if (damager!=null && (target instanceof Monster)) {
|
||||
Monster m = (Monster)target;
|
||||
@ -2556,6 +2565,7 @@ public class GenericFunctions {
|
||||
} else {
|
||||
TwosideKeeper.monsterdata.put(m.getUniqueId(),new MonsterStructure(damager));
|
||||
}
|
||||
TwosideKeeper.habitat_data.addNewStartingLocation(target);
|
||||
}
|
||||
aPlugin.API.sendEntityHurtAnimation(target);
|
||||
TwosideKeeper.log("Call event with "+dmg, 5);
|
||||
|
@ -1,15 +1,183 @@
|
||||
package sig.plugin.TwosideKeeper.HelperStructures.Common;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Monster;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import sig.plugin.TwosideKeeper.TwosideKeeper;
|
||||
import sig.plugin.TwosideKeeper.HelperStructures.ServerType;
|
||||
|
||||
public class Habitation {
|
||||
HashMap<String,Integer> locationhashes;
|
||||
HashMap<UUID,Location> startinglocs;
|
||||
public HashMap<String,Integer> locationhashes;
|
||||
public HashMap<UUID,Location> startinglocs;
|
||||
|
||||
public Habitation() {
|
||||
locationhashes = new HashMap<String,Integer>();
|
||||
startinglocs = new HashMap<UUID,Location>();
|
||||
}
|
||||
|
||||
// Returns false if the new starting location is not allowed.
|
||||
public boolean addNewStartingLocation(LivingEntity l) {
|
||||
if (l instanceof Monster) {
|
||||
String hash = getLocationHash(l.getLocation());
|
||||
if (locationhashes.containsKey(hash)) {
|
||||
int spawnamt = locationhashes.get(hash);
|
||||
TwosideKeeper.log("[Habitat]Spawn Amount was "+spawnamt+". "+((0.5/(spawnamt+1))*100)+"% chance to fail.",4);
|
||||
if (Math.random()<=(0.5/(spawnamt+1))) {
|
||||
TwosideKeeper.log("[Habitat]It failed.",4);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
TwosideKeeper.log("[Habitat]No hash exists for this location yet. Created new hash: "+hash,5);
|
||||
}
|
||||
startinglocs.put(l.getUniqueId(), l.getLocation());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void addKillToLocation(LivingEntity l) {
|
||||
String hash = getLocationHash(startinglocs.get(l.getUniqueId()));
|
||||
if (locationhashes.containsKey(hash)) {
|
||||
int spawnamt = locationhashes.get(hash);
|
||||
locationhashes.put(hash,++spawnamt);
|
||||
}
|
||||
else {
|
||||
locationhashes.put(hash,1);
|
||||
}
|
||||
}
|
||||
|
||||
public void increaseHabitationLevels() {
|
||||
for(int i=0;i<locationhashes.keySet().toArray().length;i++) {
|
||||
String hash = (String)locationhashes.keySet().toArray()[i];
|
||||
int spawnamt = locationhashes.get(hash);
|
||||
TwosideKeeper.log("[Habitat]Habitat Location "+hash+" has Spawn Amont "+spawnamt+".",4);
|
||||
if (spawnamt<20) {
|
||||
locationhashes.remove(hash);
|
||||
TwosideKeeper.log("[Habitat]It's now clear~!",4);
|
||||
i--;
|
||||
} else {
|
||||
locationhashes.put(hash, (int)(spawnamt*0.9));
|
||||
TwosideKeeper.log("[Habitat]It's now "+(int)(spawnamt*0.9)+"!",4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeStartingLocation(LivingEntity l) {
|
||||
if (startinglocs.containsKey(l.getUniqueId())) {
|
||||
startinglocs.remove(l.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
public String getLocationHash(Location l) {
|
||||
if (l!=null) {
|
||||
return (int)(l.getX()/16)+" "+(int)(l.getZ()/16);
|
||||
} else {
|
||||
TwosideKeeper.log("[ERROR][Habitat]Could not get Location Hash!!! Probably undefined Player->Enemy hit interaction!", 1);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public void saveLocationHashesToConfig() {
|
||||
File file = new File(TwosideKeeper.plugin.getDataFolder()+"/locationhashes.data");
|
||||
|
||||
// if file doesnt exists, then create it
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
file.createNewFile();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
try(
|
||||
FileWriter fw = new FileWriter(TwosideKeeper.plugin.getDataFolder()+"/locationhashes.data", false);
|
||||
BufferedWriter bw = new BufferedWriter(fw);)
|
||||
{
|
||||
for(int i=0;i<locationhashes.keySet().toArray().length;i++) {
|
||||
bw.write((String)locationhashes.keySet().toArray()[i]+","+locationhashes.get((String)locationhashes.keySet().toArray()[i]));
|
||||
bw.newLine();
|
||||
}
|
||||
TwosideKeeper.log("[Habitat]Saved "+(locationhashes.keySet().toArray().length)+" habitats successfully.",2);
|
||||
bw.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
//exception handling left as an exercise for the reader
|
||||
}
|
||||
}
|
||||
|
||||
public void loadLocationHashesFromConfig() {
|
||||
File file = new File(TwosideKeeper.plugin.getDataFolder()+"/locationhashes.data");
|
||||
|
||||
// if file doesnt exists, then create it
|
||||
if (file.exists()) {
|
||||
try(
|
||||
FileReader fw = new FileReader(TwosideKeeper.plugin.getDataFolder()+"/locationhashes.data");
|
||||
BufferedReader bw = new BufferedReader(fw);)
|
||||
{
|
||||
String readline = bw.readLine();
|
||||
int lines = 0;
|
||||
do {
|
||||
if (readline!=null) {
|
||||
lines++;
|
||||
String[] split = readline.split(",");
|
||||
String hash = split[0];
|
||||
int amt = Integer.parseInt(split[1]);
|
||||
if (locationhashes.containsKey(hash)) {
|
||||
int spawnamt = locationhashes.get(hash);
|
||||
locationhashes.put(hash,spawnamt+amt);
|
||||
}
|
||||
else {
|
||||
locationhashes.put(hash,amt);
|
||||
}
|
||||
TwosideKeeper.log("[Habitat]Loaded Habitat "+hash+" with spawn amount "+locationhashes.get(hash),4);
|
||||
readline = bw.readLine();
|
||||
}} while (readline!=null);
|
||||
TwosideKeeper.log("[Habitat]Loaded "+lines+" habitats successfully.",2);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
//exception handling left as an exercise for the reader
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getHabitationStatus(int amt) {
|
||||
if (amt<=10) {
|
||||
return ChatColor.DARK_GREEN+"Fruitful";
|
||||
} else
|
||||
if (amt<=25) {
|
||||
return ChatColor.GREEN+"Habitable";
|
||||
} else
|
||||
if (amt<=40) {
|
||||
return ChatColor.YELLOW+"Moderate";
|
||||
} else
|
||||
if (amt<=80) {
|
||||
return ChatColor.GOLD+"Poor";
|
||||
} else
|
||||
if (amt<=240) {
|
||||
return ChatColor.RED+"Sparse";
|
||||
} else
|
||||
{
|
||||
return ChatColor.DARK_RED+"Unhabitable";
|
||||
}
|
||||
}
|
||||
|
||||
public String getHabitationLevel(Location l) {
|
||||
String hash = getLocationHash(l);
|
||||
if (locationhashes.containsKey(hash)) {
|
||||
return getHabitationStatus(locationhashes.get(hash))+((TwosideKeeper.SERVER_TYPE!=ServerType.MAIN)?locationhashes.get(hash):"");
|
||||
} else {
|
||||
return getHabitationStatus(0)+((TwosideKeeper.SERVER_TYPE!=ServerType.MAIN)?locationhashes.get(hash):"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package sig.plugin.TwosideKeeper;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
|
||||
import sig.plugin.TwosideKeeper.HelperStructures.ItemCube;
|
||||
@ -17,65 +18,67 @@ public class ItemCubeWindow {
|
||||
}
|
||||
|
||||
public static void addItemCubeWindow(Player p, int id, int size) {
|
||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
|
||||
PlayerStructure pd = (PlayerStructure)TwosideKeeper.playerdata.get(p.getUniqueId());
|
||||
pd.openeditemcube.add(new ItemCubeWindow(id, size));
|
||||
pd.opened_inventory = true;
|
||||
TwosideKeeper.log("Item Cube Window added. List is now size "+pd.openeditemcube.size(),2);
|
||||
}
|
||||
|
||||
public static void popItemCubeWindow(Player p) {
|
||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
|
||||
PlayerStructure pd = (PlayerStructure)TwosideKeeper.playerdata.get(p.getUniqueId());
|
||||
if (!pd.opened_inventory &&
|
||||
pd.openeditemcube.size()>0) {
|
||||
ItemCubeWindow window = pd.openeditemcube.remove(pd.openeditemcube.size()-1);
|
||||
TwosideKeeper.log("Item Cube Window removed. List is now size "+pd.openeditemcube.size(),2);
|
||||
pd.opened_inventory=true;
|
||||
TwosideKeeper.log("Popped one.",2);
|
||||
ItemCubeWindow window = pd.openeditemcube.remove(pd.openeditemcube.size()-1);
|
||||
openItemCube(p,window.id,window.size,false); //Open this item cube without adding it to the list. We're not nesting this one.
|
||||
}
|
||||
TwosideKeeper.log("pd.opened_inventory was "+pd.opened_inventory+". List size is "+pd.openeditemcube.size(),2);
|
||||
}
|
||||
|
||||
public static void removeAllItemCubeWindows(Player p) {
|
||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
|
||||
PlayerStructure pd = (PlayerStructure)TwosideKeeper.playerdata.get(p.getUniqueId());
|
||||
pd.openeditemcube.clear();
|
||||
}
|
||||
|
||||
//New open item cube method to handle all opening of item cubes.
|
||||
public static void openItemCube(Player p, int id, int size, boolean addToList) {
|
||||
TwosideKeeper.log("Called.", 2);
|
||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
|
||||
PlayerStructure pd = (PlayerStructure)TwosideKeeper.playerdata.get(p.getUniqueId());
|
||||
if (addToList &&
|
||||
isViewingItemCubeInventory(p)) {
|
||||
addItemCubeWindow(p,getViewingItemCubeID(p),getViewingItemCubeInventorySize(p));
|
||||
}
|
||||
if (!ItemCube.isSomeoneViewingItemCube(id,p)) {
|
||||
InventoryView newinv = p.openInventory(Bukkit.getServer().createInventory(p, size, "Item Cube #"+id));
|
||||
TwosideKeeper.loadItemCubeInventory(newinv.getTopInventory(),newinv);
|
||||
TwosideKeeper.log("This should be activated",2);
|
||||
Inventory inv = Bukkit.getServer().createInventory(p, size, "Item Cube #"+id);
|
||||
InventoryView newinv = p.openInventory(inv);
|
||||
TwosideKeeper.loadItemCubeInventory(inv,newinv);
|
||||
pd.isViewingItemCube=true;
|
||||
p.playSound(p.getLocation(), Sound.BLOCK_CHEST_OPEN, 1.0f, 1.0f);
|
||||
} else {
|
||||
//ItemCube.displayErrorMessage(p);
|
||||
p.openInventory(ItemCube.getViewingItemCubeInventory(id, p));
|
||||
pd.isViewingItemCube=true;
|
||||
p.playSound(p.getLocation(), Sound.BLOCK_CHEST_OPEN, 1.0f, 1.0f);
|
||||
}
|
||||
pd.isViewingItemCube=true;
|
||||
pd.opened_inventory=false;
|
||||
}
|
||||
|
||||
public static boolean isViewingItemCubeInventory(Player p) {
|
||||
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
|
||||
TwosideKeeper.log("Are we viewing it? "+pd.isViewingItemCube,2);
|
||||
return pd.isViewingItemCube;
|
||||
PlayerStructure pd = (PlayerStructure)TwosideKeeper.playerdata.get(p.getUniqueId());
|
||||
return p.getOpenInventory().getTopInventory().getTitle().contains("Item Cube #");
|
||||
}
|
||||
|
||||
public static int getViewingItemCubeID(Player p) {
|
||||
if (p.getOpenInventory().getTitle().contains("#")) {
|
||||
String inventoryTitle = p.getOpenInventory().getTitle();
|
||||
if (isViewingItemCubeInventory(p)) {
|
||||
String inventoryTitle = p.getOpenInventory().getTopInventory().getTitle();
|
||||
return Integer.parseInt(inventoryTitle.split("#")[1]);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static int getViewingItemCubeInventorySize(Player p) {
|
||||
return p.getOpenInventory().getTopInventory().getSize();
|
||||
if (isViewingItemCubeInventory(p)) {
|
||||
return p.getOpenInventory().getTopInventory().getSize();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,8 @@ public class MonsterController {
|
||||
}
|
||||
if (ylv>=128) {
|
||||
//This is a 95% chance this will despawn.
|
||||
if (Math.random()<=0.95 && !ent.getWorld().hasStorm()) {
|
||||
if (Math.random()<=0.95 && !ent.getWorld().hasStorm() &&
|
||||
ent.getWorld().getName().equalsIgnoreCase("world")) {
|
||||
ent.remove();
|
||||
return false;
|
||||
} else {
|
||||
@ -73,7 +74,8 @@ public class MonsterController {
|
||||
} else
|
||||
if (ylv>=64) {
|
||||
//This is a 90% chance this will despawn.
|
||||
if (Math.random()<=0.90 && !ent.getWorld().hasStorm()) {
|
||||
if (Math.random()<=0.90 && !ent.getWorld().hasStorm() &&
|
||||
ent.getWorld().getName().equalsIgnoreCase("world")) {
|
||||
ent.remove();
|
||||
return false;
|
||||
} else {
|
||||
|
@ -688,7 +688,7 @@ public class NewCombat {
|
||||
}
|
||||
}
|
||||
|
||||
static LivingEntity getDamagerEntity(Entity damager) {
|
||||
public static LivingEntity getDamagerEntity(Entity damager) {
|
||||
return (damager instanceof LivingEntity)?((LivingEntity)damager):
|
||||
((damager instanceof Projectile) && (((Projectile)damager).getShooter() instanceof LivingEntity))?(LivingEntity)((Projectile)damager).getShooter():null;
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ import org.bukkit.entity.LingeringPotion;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||
import org.bukkit.entity.ThrownPotion;
|
||||
@ -193,6 +194,7 @@ import sig.plugin.TwosideKeeper.HelperStructures.UpgradePath;
|
||||
import sig.plugin.TwosideKeeper.HelperStructures.WorldShop;
|
||||
import sig.plugin.TwosideKeeper.HelperStructures.WorldShopSession;
|
||||
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
|
||||
import sig.plugin.TwosideKeeper.HelperStructures.Common.Habitation;
|
||||
import sig.plugin.TwosideKeeper.Logging.BowModeLogger;
|
||||
import sig.plugin.TwosideKeeper.Logging.DamageLogger;
|
||||
import sig.plugin.TwosideKeeper.Logging.LootLogger;
|
||||
@ -264,6 +266,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
|
||||
//Bank timers and users.
|
||||
public static HashMap banksessions;
|
||||
public static Habitation habitat_data;
|
||||
|
||||
public static Plugin plugin;
|
||||
public int sleepingPlayers=0;
|
||||
@ -323,6 +326,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
Loot_Logger = new LootLogger();
|
||||
|
||||
chargezombies = new ArrayList<ChargeZombie>();
|
||||
habitat_data = new Habitation();
|
||||
habitat_data.loadLocationHashesFromConfig();
|
||||
|
||||
TwosideRecyclingCenter = new RecyclingCenter();
|
||||
TwosideRecyclingCenter.loadConfig();
|
||||
@ -443,6 +448,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
//MOTD: "Thanks for playing on Sig's Minecraft!\n*bCheck out http://z-gamers.net/mc for update info!\n*aReport any bugs you find at http://zgamers.domain.com/mc/"
|
||||
getMOTD();
|
||||
getServer().broadcastMessage(ChatColor.translateAlternateColorCodes('*', MOTD));
|
||||
habitat_data.increaseHabitationLevels();
|
||||
habitat_data.startinglocs.clear();
|
||||
/*
|
||||
getServer().broadcastMessage("Thanks for playing on Sig's Minecraft!");
|
||||
getServer().broadcastMessage(ChatColor.AQUA+"Check out http://z-gamers.net/mc for update info!");
|
||||
@ -1135,7 +1142,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
|
||||
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
|
||||
public void onWorldSave(WorldSaveEvent ev) {
|
||||
saveOurData();
|
||||
if (ev.getWorld().getName().equalsIgnoreCase("world")) {
|
||||
saveOurData();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.LOW,ignoreCancelled = true)
|
||||
@ -3309,43 +3318,31 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
if (item_meta_lore.size()==4 && item_meta_lore.get(3).contains(ChatColor.DARK_PURPLE+"ID#")) {
|
||||
int idnumb = Integer.parseInt(item_meta_lore.get(3).split("#")[1]);
|
||||
log("This is an Item Cube.",5);
|
||||
List<HumanEntity> viewers = ev.getViewers();
|
||||
for (int i=0;i<viewers.size();i++) {
|
||||
log("Viewer "+viewers.get(i).getName()+" found.",5);
|
||||
int inventory_size;
|
||||
if (ev.getCurrentItem().getType()==Material.CHEST) {
|
||||
inventory_size=9;
|
||||
} else {
|
||||
inventory_size=27;
|
||||
}
|
||||
Player p = (Player)viewers.get(i);
|
||||
//We're going to check if the currently opened inventory is not an ender item cube. Otherwise we cannot proceed.
|
||||
/*//OLD ENDER ITEM CUBE CHECK CODE.
|
||||
* if (p.getOpenInventory().getTitle().contains("Item Cube #") &&
|
||||
itemCube_getCubeType(Integer.parseInt(p.getOpenInventory().getTitle().split("#")[1]))==CubeType.ENDER &&
|
||||
ev.getRawSlot()<27) {
|
||||
p.sendMessage("Cannot access another item cube due to being inside an ender item cube.");
|
||||
//p.openInventory(Bukkit.getServer().createInventory(p, inventory_size, "Item Cube #"+Integer.parseInt(p.getOpenInventory().getTitle().split("#")[1])));
|
||||
} else {*/
|
||||
if (!ItemCube.isSomeoneViewingItemCube(idnumb,p)) {
|
||||
ev.setCancelled(true);
|
||||
ev.setResult(Result.DENY);
|
||||
//pd.itemcubeviews.add(p.getOpenInventory());
|
||||
InventoryView newinv = p.openInventory(Bukkit.getServer().createInventory(p, inventory_size, "Item Cube #"+idnumb));
|
||||
openItemCubeInventory(newinv.getTopInventory(),newinv);
|
||||
pd.isViewingItemCube=true;
|
||||
p.playSound(p.getLocation(),Sound.BLOCK_CHEST_OPEN,1.0f,1.0f);
|
||||
} else {
|
||||
ev.setCancelled(true);
|
||||
ev.setResult(Result.DENY);
|
||||
//ItemCube.displayErrorMessage(p);
|
||||
//pd.itemcubeviews.add(p.getOpenInventory());
|
||||
p.openInventory(ItemCube.getViewingItemCubeInventory(idnumb, p));
|
||||
pd.isViewingItemCube=true;
|
||||
p.playSound(p.getLocation(), Sound.BLOCK_CHEST_OPEN, 1.0f, 1.0f);
|
||||
}
|
||||
//}
|
||||
}
|
||||
Player p = (Player)ev.getWhoClicked();
|
||||
int inventory_size;
|
||||
if (ev.getCurrentItem().getType()==Material.CHEST) {
|
||||
inventory_size=9;
|
||||
} else {
|
||||
inventory_size=27;
|
||||
}
|
||||
if (!ItemCube.isSomeoneViewingItemCube(idnumb,p)) {
|
||||
log("Attempting to open",5);
|
||||
ev.setCancelled(true);
|
||||
ev.setResult(Result.DENY);
|
||||
//pd.itemcubeviews.add(p.getOpenInventory());
|
||||
InventoryView newinv = p.openInventory(Bukkit.getServer().createInventory(p, inventory_size, "Item Cube #"+idnumb));
|
||||
openItemCubeInventory(newinv.getTopInventory(),newinv);
|
||||
pd.isViewingItemCube=true;
|
||||
p.playSound(p.getLocation(),Sound.BLOCK_CHEST_OPEN,1.0f,1.0f);
|
||||
} else {
|
||||
ev.setCancelled(true);
|
||||
ev.setResult(Result.DENY);
|
||||
//ItemCube.displayErrorMessage(p);
|
||||
//pd.itemcubeviews.add(p.getOpenInventory());
|
||||
p.openInventory(ItemCube.getViewingItemCubeInventory(idnumb, p));
|
||||
pd.isViewingItemCube=true;
|
||||
p.playSound(p.getLocation(), Sound.BLOCK_CHEST_OPEN, 1.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3469,6 +3466,13 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
log("Prevented a skeleton horse from spawning at Location "+ev.getLocation().toString()+".",3);
|
||||
}
|
||||
}
|
||||
|
||||
if (ev.getEntity() instanceof Monster) {
|
||||
if (!habitat_data.addNewStartingLocation(ev.getEntity())) {
|
||||
ev.getEntity().remove();
|
||||
ev.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//A fix to make achievemnt announcements not show the healthbar!
|
||||
@ -3922,12 +3926,13 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
if (ev.getEntity() instanceof LivingEntity) {
|
||||
((LivingEntity)ev.getEntity()).setNoDamageTicks(10);
|
||||
double oldhp=((LivingEntity)ev.getEntity()).getHealth();
|
||||
GenericFunctions.subtractHealth((LivingEntity)ev.getEntity(), NewCombat.getDamagerEntity(ev.getDamager()), dmg);
|
||||
if (NewCombat.getDamagerEntity(ev.getDamager()) instanceof Player) {
|
||||
GenericFunctions.subtractHealth((LivingEntity)ev.getEntity(), NewCombat.getDamagerEntity(ev.getDamager()), dmg);
|
||||
//GenericFunctions.subtractHealth((LivingEntity)ev.getEntity(), NewCombat.getDamagerEntity(ev.getDamager()), dmg);
|
||||
if (ev.getDamager() instanceof Projectile) {
|
||||
ev.getDamager().remove();
|
||||
}
|
||||
ev.setCancelled(true);
|
||||
} else {
|
||||
//We will instead apply damage directly.
|
||||
ev.setDamage(dmg);
|
||||
}
|
||||
log(ChatColor.BLUE+" "+oldhp+"->"+((LivingEntity)ev.getEntity()).getHealth()+" HP",3);
|
||||
}
|
||||
@ -3972,6 +3977,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
}
|
||||
|
||||
if (ms!=null && (ms.GetTarget() instanceof Player)) {
|
||||
habitat_data.addKillToLocation(m);
|
||||
habitat_data.startinglocs.remove(m.getUniqueId());
|
||||
log("Killed by a player.",5);
|
||||
killedByPlayer = true;
|
||||
Player p = (Player)ms.GetTarget();
|
||||
@ -5131,6 +5138,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
//Save user configs here too.
|
||||
saveAllUserConfigs();
|
||||
|
||||
habitat_data.saveLocationHashesToConfig();
|
||||
|
||||
log("[TASK] Configurations have been saved successfully.",3);
|
||||
}
|
||||
|
||||
@ -5981,6 +5990,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
|
||||
pd.damagedealt=store2;
|
||||
pd.damagereduction=store1;
|
||||
DecimalFormat df = new DecimalFormat("0.0");
|
||||
p.sendMessage("Habitat Quality: "+habitat_data.getHabitationLevel(p.getLocation()));
|
||||
p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Base Damage: "+ChatColor.RESET+""+ChatColor.DARK_PURPLE+df.format(store2));
|
||||
p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Damage Reduction: "+ChatColor.RESET+""+ChatColor.DARK_AQUA+df.format((1.0-store1)*100)+"%");
|
||||
p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Dodge Chance: "+ChatColor.RESET+""+ChatColor.DARK_AQUA+df.format((GenericFunctions.CalculateDodgeChance(p))*100)+"%");
|
||||
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Monster;
|
||||
@ -151,6 +152,9 @@ public final class TwosideKeeperAPI {
|
||||
public static void DealModifiedDamageToEntity(ItemStack weapon, LivingEntity damager, LivingEntity target) {
|
||||
TwosideKeeper.DealDamageToMob(weapon, damager, target);
|
||||
}
|
||||
public static void DealDamageToEntity(double dmg, LivingEntity target, Entity damager) {
|
||||
GenericFunctions.DealDamageToMob(dmg, target, damager);
|
||||
}
|
||||
|
||||
//Message COMMANDS.
|
||||
public static void playMessageNotification(Player sender) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user