diff --git a/TwosideKeeper.jar b/TwosideKeeper.jar index ccaa32d..ce285f2 100644 Binary files a/TwosideKeeper.jar and b/TwosideKeeper.jar differ diff --git a/src/plugin.yml b/src/plugin.yml index 403d8d3..2846e8b 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: TwosideKeeper main: sig.plugin.TwosideKeeper.TwosideKeeper -version: 3.10.8 +version: 3.10.9 loadbefore: [aPlugin] commands: money: diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactAbility.java b/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactAbility.java index 4476e05..fb930d7 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactAbility.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/ArtifactAbility.java @@ -113,7 +113,7 @@ public enum ArtifactAbility { new double[]{1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0},10,1,UpgradePath.ALL,1), GREED("Greed","Increases Drop rate by [VAL]% . Health is halved, health regeneration is halved. Each kill has a [GREEDCHANCE]% chance to consume the Greed buff."+TemporarySkill(true),new double[]{1,2,3,4,5,7,9,11,13,15,17,19,25,35,50}, new double[]{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0},10,10,UpgradePath.ALL,1), - GROWTH("Growth","Recovers 20% Potential to your Artifact."+TemporarySkill(false),new double[]{100,100,100,100,100,100,100,100,100,100}, + GROWTH("Growth","Sets the Potential of your Artifact to 20%."+TemporarySkill(false),new double[]{100,100,100,100,100,100,100,100,100,100}, new double[]{2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0},1,10,UpgradePath.ALL,1), /*REMOVE_CURSE("Remove Curse",ChatColor.GRAY+"[Unimplemented] Removes a level of a curse from the Artifact.",new double[]{-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0}, new double[]{0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0},1,1000,UpgradePath.ALL),*/ @@ -474,7 +474,7 @@ public enum ArtifactAbility { } if (ability.equals(ArtifactAbility.GROWTH)) { removeEnchantment(ArtifactAbility.GROWTH,item); - AwakenedArtifact.setPotential(item, AwakenedArtifact.getPotential(item)+20); + AwakenedArtifact.setPotential(item, 20); AwakenedArtifact.setMaxAP(item, AwakenedArtifact.getMaxAP(item)-1); } int apamt = AwakenedArtifact.getAP(item); diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java index 83a9d3f..9e5bb1c 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java @@ -90,8 +90,10 @@ import sig.plugin.TwosideKeeper.HelperStructures.PlayerMode; import sig.plugin.TwosideKeeper.HelperStructures.WorldShop; import sig.plugin.TwosideKeeper.HelperStructures.Utils.ArrayUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.ArtifactUtils; +import sig.plugin.TwosideKeeper.HelperStructures.Utils.ItemCubeUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.ItemUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.SoundUtils; +import sig.plugin.TwosideKeeper.HelperStructures.Utils.TextUtils; public class GenericFunctions { @@ -3312,11 +3314,68 @@ public class GenericFunctions { //TODO Item Cube Contents list. private static void UpdateItemCubeContentsList(ItemStack item) { - /*if (ItemUtils.isValidLoreItem(item) && - item.getItemMeta().getLore().size()>=4 && - ) { - - }*/ + if (ItemUtils.isValidLoreItem(item) && + item.getItemMeta().getLore().size()>=4 && + ItemUtils.LoreContainsSubstring(item, ChatColor.DARK_PURPLE+"ID#")) { + //This is an item cube. Update its lore. + int id = Integer.parseInt(ItemUtils.GetLoreLineContainingSubstring(item, ChatColor.DARK_PURPLE+"ID#").split("#")[1]); + if (TwosideKeeper.itemcube_updates.containsKey(id)) { + ItemUtils.DeleteAllLoreLinesAtAndAfterLineContainingSubstring(item, ChatColor.WHITE+"Contents ("); + ItemUtils.addLore(item, ChatColor.WHITE+"Contents ("+GetItemCubeSpace(id)+"):"); + for (ItemStack it : TwosideKeeper.itemcube_updates.get(id)) { + ItemUtils.addLore(item, ChatColor.GRAY+" - "+GenericFunctions.UserFriendlyMaterialName(it)+(it.getAmount()>1?ChatColor.YELLOW+" x"+it.getAmount():"")); + } + } + + if (item.getType()==Material.HOPPER_MINECART) { + //Filter Cube. Add "Filtering" list. + Hopper h = ItemCubeUtils.getFilterCubeHopper(id); + Inventory inv = h.getInventory(); + ItemStack[] items = inv.getContents(); + ItemUtils.DeleteAllLoreLinesAtAndAfterLineContainingSubstring(item, ChatColor.AQUA+" "); + ItemUtils.addLore(item, ChatColor.AQUA+" "); + ItemUtils.addLore(item, ChatColor.AQUA+"Filtering:"); + for (ItemStack it : items) { + if (ItemUtils.isValidItem(it)) { + ItemUtils.addLore(item, ChatColor.DARK_AQUA+" - "+GenericFunctions.UserFriendlyMaterialName(it)); + } + } + return; + } + return; + } + if (BaublePouch.isBaublePouch(item)) { + int id = BaublePouch.getBaublePouchID(item); + List items = BaublePouch.getBaublePouchContents(id); + ItemUtils.DeleteAllLoreLinesAtAndAfterLineContainingSubstring(item, ChatColor.WHITE+"Contents ("); + ItemUtils.addLore(item, ChatColor.WHITE+"Contents ("+GetBaubleSpace(id)+"):"); + for (ItemStack it : items) { + ItemUtils.addLore(item, ChatColor.GRAY+" - "+GenericFunctions.UserFriendlyMaterialName(it)+(it.getAmount()>1?ChatColor.YELLOW+" x"+it.getAmount():"")); + } + return; + } + } + + private static String GetItemCubeSpace(int id) { + List items = ItemCubeUtils.getItemCubeContents(id); + int count=0; + for (ItemStack item : items) { + if (ItemUtils.isValidItem(item)) { + count++; + } + } + return TextUtils.GetColorBasedOnPercent((items.size()-count)/(double)items.size())+""+count+ChatColor.RESET+"/"+items.size(); + } + + private static String GetBaubleSpace(int id) { + int count=0; + List items = BaublePouch.getBaublePouchContents(id); + for (ItemStack item : items) { + if (ItemUtils.isValidItem(item)) { + count++; + } + } + return TextUtils.GetColorBasedOnPercent((items.size()-count)/9d)+""+count+ChatColor.RESET+"/9"; } private static void UpdateOldQuivers(ItemStack item) { @@ -3406,7 +3465,7 @@ public class GenericFunctions { } private static void UpdateVials(ItemStack item) { - if (item.getType()==Material.POTION) { + if (item!=null && item.getType()==Material.POTION) { if (item.getItemMeta().hasLore() && item.getItemMeta().getLore().contains("A fantastic potion, it comes straight")) { //This is a special potion. Attempt to update it. @@ -3628,11 +3687,13 @@ public class GenericFunctions { } else { p.sendMessage(ChatColor.GOLD+""+ChatColor.BOLD+"Unlucky! "+ChatColor.RESET+ChatColor.DARK_RED+"Your "+ChatColor.YELLOW+((bauble.hasItemMeta() && bauble.getItemMeta().hasDisplayName())?bauble.getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(bauble))+ChatColor.DARK_RED+" has broken!"); inv.setItem(i, new ItemStack(Material.AIR)); + GenericFunctions.UpdateItemLore(pouch); } SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f); } else { p.sendMessage(ChatColor.GOLD+""+ChatColor.BOLD+"Unlucky! "+ChatColor.RESET+ChatColor.DARK_RED+"Your "+ChatColor.YELLOW+((bauble.hasItemMeta() && bauble.getItemMeta().hasDisplayName())?bauble.getItemMeta().getDisplayName():GenericFunctions.UserFriendlyMaterialName(bauble))+ChatColor.DARK_RED+" has broken!"); inv.setItem(i, new ItemStack(Material.AIR)); + GenericFunctions.UpdateItemLore(pouch); SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f); } } diff --git a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/TextUtils.java b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/TextUtils.java index 9612343..8b7ecdc 100644 --- a/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/TextUtils.java +++ b/src/sig/plugin/TwosideKeeper/HelperStructures/Utils/TextUtils.java @@ -23,4 +23,25 @@ public class TextUtils { ChatColor[] choices = new ChatColor[]{ChatColor.DARK_AQUA,ChatColor.DARK_BLUE,ChatColor.DARK_GRAY,ChatColor.DARK_GREEN,ChatColor.DARK_PURPLE,ChatColor.DARK_RED,ChatColor.GOLD}; return choices[(int)(Math.random()*choices.length)]; } + + public static ChatColor GetColorBasedOnPercent(double pct) { + if (pct>0.75) { + return ChatColor.DARK_GREEN; + } else + if (pct>0.5) { + return ChatColor.GREEN; + } else + if (pct>0.33) { + return ChatColor.YELLOW; + } else + if (pct>0.25) { + return ChatColor.GOLD; + } else + if (pct>0.1) { + return ChatColor.RED; + } else + { + return ChatColor.DARK_RED; + } + } } diff --git a/src/sig/plugin/TwosideKeeper/PlayerStructure.java b/src/sig/plugin/TwosideKeeper/PlayerStructure.java index 8e4b4f0..e2b935b 100644 --- a/src/sig/plugin/TwosideKeeper/PlayerStructure.java +++ b/src/sig/plugin/TwosideKeeper/PlayerStructure.java @@ -193,6 +193,8 @@ public class PlayerStructure { public boolean equipweapons=true; public boolean equiparmor=true; + List equipmentset = new ArrayList(); + //Needs the instance of the player object to get all other info. Only to be called at the beginning. @SuppressWarnings("deprecation") public PlayerStructure(Player p, long serverTickTime) { diff --git a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java index 8933f6e..f674fa8 100644 --- a/src/sig/plugin/TwosideKeeper/TwosideKeeper.java +++ b/src/sig/plugin/TwosideKeeper/TwosideKeeper.java @@ -33,6 +33,7 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.block.Chest; import org.bukkit.block.DoubleChest; +import org.bukkit.block.Dropper; import org.bukkit.block.Hopper; import org.bukkit.block.Sign; import org.bukkit.command.Command; @@ -445,7 +446,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener { public static long last_snow_golem = 0; public static File filesave; public static HashMap playerdata; - public static HashMap livingentitydata; + public static HashMap livingentitydata; + public static HashMap> itemcube_updates; public static SpleefManager TwosideSpleefGames; public static WorldShopManager TwosideShops; public static MysteriousEssenceLogger EssenceLogger; //The logger for Essences. @@ -961,7 +963,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener { //Initialize Player Data structure. playerdata = new HashMap(); banksessions = new HashMap(); - livingentitydata = new HashMap(); + livingentitydata = new HashMap(); + itemcube_updates = new HashMap>(); validsetitems.add(Material.LEATHER_BOOTS); validsetitems.add(Material.LEATHER_CHESTPLATE); @@ -3579,7 +3582,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } List save_items = new ArrayList(); - for (int i=0;i itemcube_list = new ArrayList(); + for (ItemStack item : save_items) { + if (ItemUtils.isValidItem(item)) { + boolean found=false; + for (int j=0;j item_lore = ev.getCurrentItem().getItemMeta().getLore(); if (item_lore.size()!=4) { @@ -4411,13 +4448,51 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } else { cubetype=CubeType.NORMAL; } - itemCube_saveConfig(ITEMCUBEID, new ArrayList(), cubetype); + + if (items!=null) { + Inventory virtualinventory = Bukkit.createInventory((Player)ev.getWhoClicked(), cubetype.getSize()); + + HashMap remaining = virtualinventory.addItem(items); + + List savelist = new ArrayList(); + List itemlist = new ArrayList(); + for (ItemStack it : virtualinventory.getContents()) { + if (ItemUtils.isValidItem(it)) { + savelist.add(it); + boolean found=false; + for (int j=0;j(), cubetype); + } ITEMCUBEID++; } return; } } } + if (BaublePouch.isBaublePouch(ev.getCurrentItem())) { //Modify the Bauble Pouch # line to the next bauble pouch ID. if (ev.isShiftClick()) { @@ -4706,6 +4781,15 @@ public class TwosideKeeper extends JavaPlugin implements Listener { DropDeathInventoryContents(p, deathloc, 0); } + if (ev.getInventory().getHolder() instanceof Dropper || + ev.getInventory().getHolder() instanceof Hopper) { + for (ItemStack item : p.getInventory().getContents()) { + if (ItemUtils.isValidItem(item)) { + GenericFunctions.UpdateItemLore(item); + } + } + } + PlayerStructure pd = (PlayerStructure) playerdata.get(p.getUniqueId()); pd.isViewingInventory=false; log("Closed Inventory.",5); @@ -4720,10 +4804,24 @@ public class TwosideKeeper extends JavaPlugin implements Listener { int id = Integer.parseInt(ev.getInventory().getTitle().split("#")[1]); List itemcube_contents = new ArrayList(); + List itemcube_list = new ArrayList(); for (int i=0;i=DeathManager.CalculateDeathPrice(player)) { + //player.getInventory().addItem(ev.getCurrentItem()); + if (ev.getCurrentItem()!=null && + ev.getCurrentItem().getType()!=Material.AIR) { + //player.getLocation().getWorld().dropItemNaturally(player.getLocation(), ev.getCurrentItem()).setPickupDelay(0); + boolean equipped = AutoEquipItem(ev.getCurrentItem(),player); + if (!equipped) { + GenericFunctions.giveItem(player, ev.getCurrentItem()); + } + ev.setCurrentItem(new ItemStack(Material.AIR)); + + final DecimalFormat df = new DecimalFormat("0.00"); + Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { + @Override + public void run() { + player.sendMessage(ChatColor.BLUE+"New Balance: "+ChatColor.GREEN+"$"+df.format((getPlayerMoney(player)+getPlayerBankMoney(player)-DeathManager.CalculateDeathPrice(player)*DeathManager.CountOccupiedSlots(player.getInventory())))); + } + },1); + } + } else { + player.sendMessage(ChatColor.RED+"You cannot afford to salvage any more items!"); + } + } + ev.setCancelled(true); + return; + } + + //////////////////////////////////////////////////// + ////////////////////////////// + /////////////////HANDLE DEATH STRUCTURE UP HERE. DO NOT PUT OTHER THINGS ABOVE THIS LINE. + + if (!Christmas.runInventoryClickEvent(ev)) { return; } @@ -4957,6 +5095,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } else { ev.setCursor(new ItemStack(Material.AIR)); } + GenericFunctions.UpdateItemLore(ev.getCurrentItem()); ((Player)ev.getWhoClicked()).updateInventory(); ev.setCancelled(true); return; @@ -4976,37 +5115,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener { return; } - if (DeathManager.deathStructureExists(player) && ev.getInventory().getTitle().equalsIgnoreCase("Death Loot")) { - //See how many items are in our inventory. Determine final balance. - //Count the occupied slots. - if (ev.getRawSlot()<45) { - if (getPlayerMoney(player)+getPlayerBankMoney(player)-DeathManager.CalculateDeathPrice(player)*DeathManager.CountOccupiedSlots(player.getInventory())>=DeathManager.CalculateDeathPrice(player)) { - //player.getInventory().addItem(ev.getCurrentItem()); - if (ev.getCurrentItem()!=null && - ev.getCurrentItem().getType()!=Material.AIR) { - //player.getLocation().getWorld().dropItemNaturally(player.getLocation(), ev.getCurrentItem()).setPickupDelay(0); - boolean equipped = AutoEquipItem(ev.getCurrentItem(),player); - if (!equipped) { - GenericFunctions.giveItem(player, ev.getCurrentItem()); - } - ev.setCurrentItem(new ItemStack(Material.AIR)); - - final DecimalFormat df = new DecimalFormat("0.00"); - Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { - @Override - public void run() { - player.sendMessage(ChatColor.BLUE+"New Balance: "+ChatColor.GREEN+"$"+df.format((getPlayerMoney(player)+getPlayerBankMoney(player)-DeathManager.CalculateDeathPrice(player)*DeathManager.CountOccupiedSlots(player.getInventory())))); - } - },1); - } - } else { - player.sendMessage(ChatColor.RED+"You cannot afford to salvage any more items!"); - } - } - ev.setCancelled(true); - return; - } - /*if (ev.getClick()==ClickType.RIGHT && Artifact.isMalleableBase(ev.getCurrentItem())) { if (MalleableBaseQuest.getStatus(ev.getCurrentItem())==QuestStatus.UNFORMED) { StartMalleableBaseQuest((Player)ev.getWhoClicked()); @@ -5131,6 +5239,26 @@ public class TwosideKeeper extends JavaPlugin implements Listener { //ItemCubeWindow.removeAllItemCubeWindows((Player)ev.getWhoClicked()); Player p = (Player)ev.getWhoClicked(); pd = PlayerStructure.GetPlayerStructure(p); + List itemcube_list = new ArrayList(); + for (int i=0;i itemslist = new ArrayList(); + List itemcube_list = new ArrayList(); for (int i=0;i itemslist = new ArrayList(); + List itemcube_list = new ArrayList(); for (int i=0;i1?ChatColor.YELLOW+" x"+it.getAmount():"")); + } + ev.getInventory().setResult(itemcube); + return; + } + } + } //This could be our duplication recipe... if (CustomRecipe.ENDER_ITEM_CUBE_DUPLICATE.isSameRecipe(ev.getRecipe().getResult())) { @@ -8807,7 +8986,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener { } } - StringBuilder bar = new StringBuilder(Character.toString(' ')); + StringBuilder bar = new StringBuilder(); + bar.append(' '); boolean isslayer = PlayerMode.getPlayerMode(p)==PlayerMode.SLAYER; PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); @@ -8998,144 +9178,220 @@ public class TwosideKeeper extends JavaPlugin implements Listener { public static void setPlayerMaxHealth(Player p, Double ratio) { //Determine player max HP based on armor being worn. - double hp=10; //Get the base max health. - //Get all equips. - ItemStack[] equipment = {p.getInventory().getHelmet(),p.getInventory().getChestplate(),p.getInventory().getLeggings(),p.getInventory().getBoots()}; - double maxdeduction=1; - for (ItemStack equip : equipment) { - if (equip!=null) { - boolean is_block_form=false; - //Determine if the piece is block form. - //If this is an artifact armor, we totally override the base damage reduction. - if (GenericFunctions.isArmor(equip) && Artifact.isArtifact(equip)) { - //Let's change up the damage. - log("This is getting through",5); - /*int dmgval = ArtifactItemType.valueOf(Artifact.returnRawTool(equip.getType())).getHealthAmt(equip.getEnchantmentLevel(Enchantment.LUCK)); - if (dmgval!=-1) { - hp += dmgval; - }*/ - } else { - if (equip.hasItemMeta() && - equip.getItemMeta().hasLore()) { - for (int j=0;j Is Block Form Check", (int)(System.nanoTime()-time));time = System.nanoTime(); + if (equip.getType().toString().contains("LEATHER")) { + //This is a leather piece. + hp+=ARMOR_LEATHER_HP; + } else if (equip.getType().toString().contains("IRON")) { + //This is an iron piece. + hp+=(is_block_form)?ARMOR_IRON2_HP:ARMOR_IRON_HP; + } else if (equip.getType().toString().contains("GOLD")) { + //This is a gold piece. + hp+=(is_block_form)?ARMOR_GOLD2_HP:ARMOR_GOLD_HP; + } else if (equip.getType().toString().contains("DIAMOND")) { + //This is a diamond piece. + hp+=(is_block_form)?ARMOR_DIAMOND2_HP:ARMOR_DIAMOND_HP; + } + TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Increase Health for Block Armor", (int)(System.nanoTime()-time));time = System.nanoTime(); } - if (equip.getType().toString().contains("LEATHER")) { - //This is a leather piece. - hp+=ARMOR_LEATHER_HP; - } else if (equip.getType().toString().contains("IRON")) { - //This is an iron piece. - hp+=(is_block_form)?ARMOR_IRON2_HP:ARMOR_IRON_HP; - } else if (equip.getType().toString().contains("GOLD")) { - //This is a gold piece. - hp+=(is_block_form)?ARMOR_GOLD2_HP:ARMOR_GOLD_HP; - } else if (equip.getType().toString().contains("DIAMOND")) { - //This is a diamond piece. - hp+=(is_block_form)?ARMOR_DIAMOND2_HP:ARMOR_DIAMOND_HP; + if (GenericFunctions.isArtifactEquip(equip)) { + //log("Add in "+GenericFunctions.getAbilityValue(ArtifactAbility.HEALTH, equip),5); + if (PlayerMode.getPlayerMode(p)==PlayerMode.RANGER) { + long time = System.nanoTime(); + hp += (double)GenericFunctions.getAbilityValue(ArtifactAbility.HEALTH, equip)/2; + TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Increase Health for Ranger Armor", (int)(System.nanoTime()-time));time = System.nanoTime(); + } else { + long time = System.nanoTime(); + hp += (double)GenericFunctions.getAbilityValue(ArtifactAbility.HEALTH, equip); + TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Increase Health for Normal Armor", (int)(System.nanoTime()-time));time = System.nanoTime(); + } + + long time = System.nanoTime(); + if (ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, equip)) { + maxdeduction /= ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, equip)?2:1; + } + TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Decrease Health based on Greed", (int)(System.nanoTime()-time));time = System.nanoTime(); } } - if (GenericFunctions.isArtifactEquip(equip)) { - log("Add in "+GenericFunctions.getAbilityValue(ArtifactAbility.HEALTH, equip),5); - if (PlayerMode.getPlayerMode(p)==PlayerMode.RANGER) { - hp += (double)GenericFunctions.getAbilityValue(ArtifactAbility.HEALTH, equip)/2; - } else { - hp += (double)GenericFunctions.getAbilityValue(ArtifactAbility.HEALTH, equip); + } + TwosideKeeper.HeartbeatLogger.AddEntry("----]> Equipment Check", (int)(System.nanoTime()-equiplooptime)); + + long time = System.nanoTime(); + //Check the hotbar for set equips. + hp+=ItemSet.GetTotalBaseAmount(GenericFunctions.getBaubles(p), p, ItemSet.GLADOMAIN); + TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Gladomain Set Increase", (int)(System.nanoTime()-time));time = System.nanoTime(); + log("Health is now "+hp,5); + if (ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, p.getEquipment().getItemInMainHand())) { + maxdeduction /= ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, p.getEquipment().getItemInMainHand())?2:1; + } + TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Greed Reduction Main Hand", (int)(System.nanoTime()-time));time = System.nanoTime(); + log("maxdeduction is "+maxdeduction,5); + + if (PlayerMode.isDefender(p)) { + hp+=10; + GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.REGENERATION,60,(p.isBlocking())?3:1,p,false); + } + TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Defender HP and Regeneration", (int)(System.nanoTime()-time));time = System.nanoTime(); + if (PlayerMode.isBarbarian(p)) { + double red = 1-CustomDamage.CalculateDamageReduction(1,p,null); + hp+=(red*2)*100; + } + TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Barbarian HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime(); + + + hp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getEquipment(p,true), p, ItemSet.DAWNTRACKER, 4, 4); + TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Dawntracker HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime(); + hp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getEquipment(p), p, ItemSet.SONGSTEEL, 2, 2); + TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Songsteel HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime(); + + /* + if (p.hasPotionEffect(PotionEffectType.ABSORPTION)) { + Collection player_effects = p.getActivePotionEffects(); + for (int i=0;i Alikahn HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime(); + hp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getEquipment(p), p, ItemSet.COMET, 2, 2); + TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Comet HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime(); + hp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getEquipment(p), p, ItemSet.CUPID, 2, 2); + TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Cupid HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime(); + hp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getEquipment(p), p, ItemSet.DONNER, 2, 2); + TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Donner HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime(); + hp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getEquipment(p), p, ItemSet.RUDOLPH, 2, 2); + TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Rudolph HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime(); + hp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getEquipment(p), p, ItemSet.OLIVE, 2, 2); + TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Olive HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime(); + hp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getEquipment(p), p, ItemSet.DASHER, 3, 3); + TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Dasher HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime(); + hp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getEquipment(p), p, ItemSet.DANCER, 3, 3); + TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Dancer HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime(); + hp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getEquipment(p), p, ItemSet.PRANCER, 3, 3); + TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Prancer HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime(); + hp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getEquipment(p), p, ItemSet.VIXEN, 3, 3); + TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Vixen HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime(); + hp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getEquipment(p), p, ItemSet.BLITZEN, 3, 3); + TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Blitzen HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime(); + /*hp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.ALIKAHN, 4, 4)+ + ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.DARNYS, 4, 4)+ + ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.LORASAADI, 4, 4)+ + ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.JAMDAK, 4, 4);*/ + + if (PlayerMode.getPlayerMode(p)==PlayerMode.NORMAL) { + hp+=10; + } + TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Adventurer Mode HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime(); + + hp*=maxdeduction; + + p.resetMaxHealth(); + if (p.getHealth()>=hp) { + p.setHealth(hp); + } + p.setMaxHealth(hp); + TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Reset Health", (int)(System.nanoTime()-time));time = System.nanoTime(); + if (!p.isDead()) { + if (ratio==null) { + p.setHealth(p.getHealth()); + } else { + //TwosideKeeper.log("Hp is "+hp+". Ratio is "+ratio+". Setting to "+, loglv); + p.setHealth(ratio*p.getMaxHealth()); + } + } + TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Set Health Ratio", (int)(System.nanoTime()-time));time = System.nanoTime(); + if (PlayerMode.getPlayerMode(p)==PlayerMode.SLAYER) { + double slayermodehp = PlayerStructure.GetPlayerStructure(p).slayermodehp; + if (ratio==null) { + if (slayermodehp>p.getMaxHealth()) { + slayermodehp = PlayerStructure.GetPlayerStructure(p).slayermodehp = p.getMaxHealth(); } + } else { + slayermodehp = PlayerStructure.GetPlayerStructure(p).slayermodehp = ratio*p.getMaxHealth(); } + p.setHealth(slayermodehp); } + TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Apply Slayer Mode HP", (int)(System.nanoTime()-time));time = System.nanoTime(); + p.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(hp); + p.setHealthScaled(false); + TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Final Fix", (int)(System.nanoTime()-time));time = System.nanoTime(); } - - //Check the hotbar for set equips. - hp+=ItemSet.GetTotalBaseAmount(GenericFunctions.getBaubles(p), p, ItemSet.GLADOMAIN); - log("Health is now "+hp,5); - if (ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, p.getEquipment().getItemInMainHand())) { - maxdeduction /= ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, p.getEquipment().getItemInMainHand())?2:1; - } - log("maxdeduction is "+maxdeduction,5); - - if (PlayerMode.isDefender(p)) { - hp+=10; - GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.REGENERATION,60,(p.isBlocking())?3:1,p,false); - } - if (PlayerMode.isBarbarian(p)) { - double red = 1-CustomDamage.CalculateDamageReduction(1,p,null); - hp+=(red*2)*100; - } - + } + - hp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getEquipment(p,true), p, ItemSet.DAWNTRACKER, 4, 4); - hp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getEquipment(p), p, ItemSet.SONGSTEEL, 2, 2); - - /* - if (p.hasPotionEffect(PotionEffectType.ABSORPTION)) { - Collection player_effects = p.getActivePotionEffects(); - for (int i=0;i newequips = UpdateEquipmentSet(p,pd); + if (pd.equipmentset.size()!=newequips.size()) { + TwosideKeeper.log(pd.equipmentset.size()+" is different from "+newequips.size(), 5); + pd.equipmentset.clear(); + pd.equipmentset.addAll(newequips); + return true; + } else { //Maybe a piece inside was updated. + boolean matches=true; + for (int i=0;i=hp) { - p.setHealth(hp); - } - p.setMaxHealth(hp); - if (!p.isDead()) { - if (ratio==null) { - p.setHealth(p.getHealth()); - } else { - //TwosideKeeper.log("Hp is "+hp+". Ratio is "+ratio+". Setting to "+, loglv); - p.setHealth(ratio*p.getMaxHealth()); + } + public static List UpdateEquipmentSet(Player p, PlayerStructure pd) { + List equips = new ArrayList(); + for (ItemStack item : GenericFunctions.getEquipment(p, true)) { + if (ItemUtils.isValidItem(item)) { + equips.add(setTo0Durability(item.clone())); } } - if (PlayerMode.getPlayerMode(p)==PlayerMode.SLAYER) { - double slayermodehp = PlayerStructure.GetPlayerStructure(p).slayermodehp; - if (ratio==null) { - if (slayermodehp>p.getMaxHealth()) { - slayermodehp = PlayerStructure.GetPlayerStructure(p).slayermodehp = p.getMaxHealth(); - } - } else { - slayermodehp = PlayerStructure.GetPlayerStructure(p).slayermodehp = ratio*p.getMaxHealth(); - } - p.setHealth(slayermodehp); + return equips; + } + private static ItemStack setTo0Durability(ItemStack item) { + if (ItemUtils.isValidItem(item)) { + item.setDurability((short)0); + return item; } - p.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(hp); - p.setHealthScaled(false); + return null; } - - - public static void updateTitle(final Player p, boolean headshot, boolean preemptive) { if (preemptive) { updateTitle(p,ChatColor.BLUE+"!");