diff --git a/TwosideKeeper.jar b/TwosideKeeper.jar index 818ef11..10d4836 100644 Binary files a/TwosideKeeper.jar and b/TwosideKeeper.jar differ diff --git a/src/plugin.yml b/src/plugin.yml index 754fd40..e347bf4 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -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. diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java index eef9d7d..7e96968 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java @@ -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); diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/Habitation.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/Habitation.java index 6ba5b42..c9faac4 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/Habitation.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/Habitation.java @@ -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 locationhashes; - HashMap startinglocs; + public HashMap locationhashes; + public HashMap startinglocs; public Habitation() { - + locationhashes = new HashMap(); + startinglocs = new HashMap(); + } + + // 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;iEnemy 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;i0) { - 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; } } diff --git a/src/sig/plugin/TwosideKeeper/MonsterController.java b/src/sig/plugin/TwosideKeeper/MonsterController.java index 308cb3a..d0476cd 100644 --- a/src/sig/plugin/TwosideKeeper/MonsterController.java +++ b/src/sig/plugin/TwosideKeeper/MonsterController.java @@ -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 { diff --git a/src/sig/plugin/TwosideKeeper/NewCombat.java b/src/sig/plugin/TwosideKeeper/NewCombat.java index 9479db5..bc5ebe8 100644 --- a/src/sig/plugin/TwosideKeeper/NewCombat.java +++ b/src/sig/plugin/TwosideKeeper/NewCombat.java @@ -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; } diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java index b2bb535..4881d93 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java @@ -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(); + 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 viewers = ev.getViewers(); - for (int i=0;i"+((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)+"%"); diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java b/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java index 284e8ff..dfaea06 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java @@ -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) {