+>Item Cubes now display their contents

+>Filter Cubes now display what they are filtering.
+>Magic chests picked up via Mover Wand can now be directly crafted as a
replacement for the normal chest slot and will automatically create an
item cube filled with the contents! This works for all Item Cube recipes
with a normal chest: Item Cube, Large Item Cube, and Filter Cubes.
>Heavily optimized the speed of the server heartbeat, improving server
performance.
>Fixed a bug causing Elite Zombies converting blocks broken using their
data values improperly.
->Modified 'Growth' to set Potential of an artifact to 20% instead of
increasing the Potential by 20%.
This commit is contained in:
sigonasr2 2017-01-17 20:26:49 -06:00
parent 336a84e93d
commit e5b96b3924
7 changed files with 508 additions and 168 deletions

Binary file not shown.

View File

@ -1,6 +1,6 @@
name: TwosideKeeper name: TwosideKeeper
main: sig.plugin.TwosideKeeper.TwosideKeeper main: sig.plugin.TwosideKeeper.TwosideKeeper
version: 3.10.8 version: 3.10.9
loadbefore: [aPlugin] loadbefore: [aPlugin]
commands: commands:
money: money:

View File

@ -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), 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}, 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), 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), 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}, /*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),*/ 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)) { if (ability.equals(ArtifactAbility.GROWTH)) {
removeEnchantment(ArtifactAbility.GROWTH,item); removeEnchantment(ArtifactAbility.GROWTH,item);
AwakenedArtifact.setPotential(item, AwakenedArtifact.getPotential(item)+20); AwakenedArtifact.setPotential(item, 20);
AwakenedArtifact.setMaxAP(item, AwakenedArtifact.getMaxAP(item)-1); AwakenedArtifact.setMaxAP(item, AwakenedArtifact.getMaxAP(item)-1);
} }
int apamt = AwakenedArtifact.getAP(item); int apamt = AwakenedArtifact.getAP(item);

View File

@ -90,8 +90,10 @@ import sig.plugin.TwosideKeeper.HelperStructures.PlayerMode;
import sig.plugin.TwosideKeeper.HelperStructures.WorldShop; import sig.plugin.TwosideKeeper.HelperStructures.WorldShop;
import sig.plugin.TwosideKeeper.HelperStructures.Utils.ArrayUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.ArrayUtils;
import sig.plugin.TwosideKeeper.HelperStructures.Utils.ArtifactUtils; 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.ItemUtils;
import sig.plugin.TwosideKeeper.HelperStructures.Utils.SoundUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.SoundUtils;
import sig.plugin.TwosideKeeper.HelperStructures.Utils.TextUtils;
public class GenericFunctions { public class GenericFunctions {
@ -3312,11 +3314,68 @@ public class GenericFunctions {
//TODO Item Cube Contents list. //TODO Item Cube Contents list.
private static void UpdateItemCubeContentsList(ItemStack item) { private static void UpdateItemCubeContentsList(ItemStack item) {
/*if (ItemUtils.isValidLoreItem(item) && if (ItemUtils.isValidLoreItem(item) &&
item.getItemMeta().getLore().size()>=4 && 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<ItemStack> 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<ItemStack> 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<ItemStack> 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) { private static void UpdateOldQuivers(ItemStack item) {
@ -3406,7 +3465,7 @@ public class GenericFunctions {
} }
private static void UpdateVials(ItemStack item) { private static void UpdateVials(ItemStack item) {
if (item.getType()==Material.POTION) { if (item!=null && item.getType()==Material.POTION) {
if (item.getItemMeta().hasLore() && if (item.getItemMeta().hasLore() &&
item.getItemMeta().getLore().contains("A fantastic potion, it comes straight")) { item.getItemMeta().getLore().contains("A fantastic potion, it comes straight")) {
//This is a special potion. Attempt to update it. //This is a special potion. Attempt to update it.
@ -3628,11 +3687,13 @@ public class GenericFunctions {
} else { } 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!"); 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)); inv.setItem(i, new ItemStack(Material.AIR));
GenericFunctions.UpdateItemLore(pouch);
} }
SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f); SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f);
} else { } 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!"); 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)); inv.setItem(i, new ItemStack(Material.AIR));
GenericFunctions.UpdateItemLore(pouch);
SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f); SoundUtils.playLocalSound(p, Sound.ENTITY_ITEM_BREAK, 1.0f, 1.0f);
} }
} }

View File

@ -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}; 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)]; 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;
}
}
} }

View File

@ -193,6 +193,8 @@ public class PlayerStructure {
public boolean equipweapons=true; public boolean equipweapons=true;
public boolean equiparmor=true; public boolean equiparmor=true;
List<ItemStack> equipmentset = new ArrayList<ItemStack>();
//Needs the instance of the player object to get all other info. Only to be called at the beginning. //Needs the instance of the player object to get all other info. Only to be called at the beginning.
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public PlayerStructure(Player p, long serverTickTime) { public PlayerStructure(Player p, long serverTickTime) {

View File

@ -33,6 +33,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockState; import org.bukkit.block.BlockState;
import org.bukkit.block.Chest; import org.bukkit.block.Chest;
import org.bukkit.block.DoubleChest; import org.bukkit.block.DoubleChest;
import org.bukkit.block.Dropper;
import org.bukkit.block.Hopper; import org.bukkit.block.Hopper;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -446,6 +447,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
public static File filesave; public static File filesave;
public static HashMap<UUID,PlayerStructure> playerdata; public static HashMap<UUID,PlayerStructure> playerdata;
public static HashMap<UUID,LivingEntityStructure> livingentitydata; public static HashMap<UUID,LivingEntityStructure> livingentitydata;
public static HashMap<Integer,List<ItemStack>> itemcube_updates;
public static SpleefManager TwosideSpleefGames; public static SpleefManager TwosideSpleefGames;
public static WorldShopManager TwosideShops; public static WorldShopManager TwosideShops;
public static MysteriousEssenceLogger EssenceLogger; //The logger for Essences. public static MysteriousEssenceLogger EssenceLogger; //The logger for Essences.
@ -962,6 +964,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
playerdata = new HashMap<UUID,PlayerStructure>(); playerdata = new HashMap<UUID,PlayerStructure>();
banksessions = new HashMap<UUID,BankSession>(); banksessions = new HashMap<UUID,BankSession>();
livingentitydata = new HashMap<UUID,LivingEntityStructure>(); livingentitydata = new HashMap<UUID,LivingEntityStructure>();
itemcube_updates = new HashMap<Integer,List<ItemStack>>();
validsetitems.add(Material.LEATHER_BOOTS); validsetitems.add(Material.LEATHER_BOOTS);
validsetitems.add(Material.LEATHER_CHESTPLATE); validsetitems.add(Material.LEATHER_CHESTPLATE);
@ -3579,7 +3582,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
} }
List<ItemStack> save_items = new ArrayList<ItemStack>(); List<ItemStack> save_items = new ArrayList<ItemStack>();
for (int i=0;i<size;i++) { for (int i=0;i<size;i++) {
save_items.add(new ItemStack(Material.AIR)); save_items.add(new ItemStack(Material.AIR));
} }
@ -3618,6 +3620,28 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
//Save the Item Cube. //Save the Item Cube.
itemCube_saveConfig(itemcube_id,save_items,cub); itemCube_saveConfig(itemcube_id,save_items,cub);
List<ItemStack> itemcube_list = new ArrayList<ItemStack>();
for (ItemStack item : save_items) {
if (ItemUtils.isValidItem(item)) {
boolean found=false;
for (int j=0;j<itemcube_list.size();j++) {
if (itemcube_list.get(j).isSimilar(item)) {
ItemStack newitem = itemcube_list.get(j).clone();
newitem.setAmount(newitem.getAmount()+item.getAmount());
itemcube_list.set(j, newitem);
found=true;
break;
}
}
if (!found) {
itemcube_list.add(item);
}
}
}
itemcube_updates.put(itemcube_id, itemcube_list);
GenericFunctions.UpdateItemLore(ev.getPlayer().getInventory().getItemInMainHand());
//This may have been a shop. Update the shop too. //This may have been a shop. Update the shop too.
WorldShop.updateShopSign(ev.getClickedBlock()); WorldShop.updateShopSign(ev.getClickedBlock());
ev.setCancelled(true); ev.setCancelled(true);
@ -4380,6 +4404,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ArrowQuiver.updateQuiverLore(ev.getCurrentItem()); ArrowQuiver.updateQuiverLore(ev.getCurrentItem());
} }
} }
if (ev.getCurrentItem().hasItemMeta()) { if (ev.getCurrentItem().hasItemMeta()) {
ItemMeta item_meta = ev.getCurrentItem().getItemMeta(); ItemMeta item_meta = ev.getCurrentItem().getItemMeta();
if (item_meta.getDisplayName()!=null && if (item_meta.getDisplayName()!=null &&
@ -4388,6 +4413,18 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if (ev.isShiftClick()) { if (ev.isShiftClick()) {
ev.setCancelled(true); ev.setCancelled(true);
} else { } else {
ItemStack[] items = null;
if (ItemUtils.isValidLoreItem(ev.getInventory().getResult())) {
for (ItemStack item : ev.getInventory()) {
if (ItemUtils.isValidItem(item) && aPlugin.API.isMoverWandChest(item)) {
items = aPlugin.API.readMoverWandChestContents(item, true);
ItemStack itemcube = ev.getInventory().getResult().clone();
ItemUtils.DeleteAllLoreLinesAtAndAfterLineContainingSubstring(itemcube, "Contents:");
ev.getInventory().setResult(itemcube);
break;
}
}
}
//We have verified this is an Item Cube. Setup an ID for this cube. //We have verified this is an Item Cube. Setup an ID for this cube.
List<String> item_lore = ev.getCurrentItem().getItemMeta().getLore(); List<String> item_lore = ev.getCurrentItem().getItemMeta().getLore();
if (item_lore.size()!=4) { if (item_lore.size()!=4) {
@ -4411,13 +4448,51 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} else { } else {
cubetype=CubeType.NORMAL; cubetype=CubeType.NORMAL;
} }
if (items!=null) {
Inventory virtualinventory = Bukkit.createInventory((Player)ev.getWhoClicked(), cubetype.getSize());
HashMap<Integer,ItemStack> remaining = virtualinventory.addItem(items);
List<ItemStack> savelist = new ArrayList<ItemStack>();
List<ItemStack> itemlist = new ArrayList<ItemStack>();
for (ItemStack it : virtualinventory.getContents()) {
if (ItemUtils.isValidItem(it)) {
savelist.add(it);
boolean found=false;
for (int j=0;j<itemlist.size();j++) {
if (itemlist.get(j).isSimilar(it)) {
ItemStack olditem = itemlist.get(j).clone();
olditem.setAmount(olditem.getAmount()+it.getAmount());
itemlist.set(j, olditem);
found=true;
break;
}
}
if (!found) {
itemlist.add(it);
}
}
}
for (Integer key : remaining.keySet()) {
ItemStack item = remaining.get(key);
GenericFunctions.giveItem((Player)ev.getWhoClicked(), item);
}
itemCube_saveConfig(ITEMCUBEID, savelist, cubetype);
TwosideKeeper.itemcube_updates.put(ITEMCUBEID, itemlist);
ItemStack newitem = ev.getInventory().getResult().clone();
GenericFunctions.UpdateItemLore(newitem);
ev.getInventory().setResult(newitem);
} else {
itemCube_saveConfig(ITEMCUBEID, new ArrayList<ItemStack>(), cubetype); itemCube_saveConfig(ITEMCUBEID, new ArrayList<ItemStack>(), cubetype);
}
ITEMCUBEID++; ITEMCUBEID++;
} }
return; return;
} }
} }
} }
if (BaublePouch.isBaublePouch(ev.getCurrentItem())) { if (BaublePouch.isBaublePouch(ev.getCurrentItem())) {
//Modify the Bauble Pouch # line to the next bauble pouch ID. //Modify the Bauble Pouch # line to the next bauble pouch ID.
if (ev.isShiftClick()) { if (ev.isShiftClick()) {
@ -4706,6 +4781,15 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
DropDeathInventoryContents(p, deathloc, 0); 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()); PlayerStructure pd = (PlayerStructure) playerdata.get(p.getUniqueId());
pd.isViewingInventory=false; pd.isViewingInventory=false;
log("Closed Inventory.",5); log("Closed Inventory.",5);
@ -4720,10 +4804,24 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
int id = Integer.parseInt(ev.getInventory().getTitle().split("#")[1]); int id = Integer.parseInt(ev.getInventory().getTitle().split("#")[1]);
List<ItemStack> itemcube_contents = new ArrayList<ItemStack>(); List<ItemStack> itemcube_contents = new ArrayList<ItemStack>();
List<ItemStack> itemcube_list = new ArrayList<ItemStack>();
for (int i=0;i<p.getOpenInventory().getTopInventory().getSize();i++) { for (int i=0;i<p.getOpenInventory().getTopInventory().getSize();i++) {
if (p.getOpenInventory().getTopInventory().getItem(i)!=null) { if (p.getOpenInventory().getTopInventory().getItem(i)!=null) {
//p.sendMessage("Saving item "+p.getOpenInventory().getTopInventory().getItem(i).toString()+" in slot "+i); //p.sendMessage("Saving item "+p.getOpenInventory().getTopInventory().getItem(i).toString()+" in slot "+i);
itemcube_contents.add(p.getOpenInventory().getTopInventory().getItem(i)); itemcube_contents.add(p.getOpenInventory().getTopInventory().getItem(i));
boolean found=false;
for (int j=0;j<itemcube_list.size();j++) {
if (itemcube_list.get(j).isSimilar(p.getOpenInventory().getTopInventory().getItem(i))) {
ItemStack newitem = itemcube_list.get(j).clone();
newitem.setAmount(newitem.getAmount()+p.getOpenInventory().getTopInventory().getItem(i).getAmount());
itemcube_list.set(j, newitem);
found=true;
break;
}
}
if (!found) {
itemcube_list.add(p.getOpenInventory().getTopInventory().getItem(i));
}
} else { } else {
//p.sendMessage("Saving item AIR in slot "+i); //p.sendMessage("Saving item AIR in slot "+i);
itemcube_contents.add(new ItemStack(Material.AIR)); itemcube_contents.add(new ItemStack(Material.AIR));
@ -4732,8 +4830,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
CubeType cub = p.getOpenInventory().getTopInventory().getSize()==9?CubeType.NORMAL:p.getOpenInventory().getTopInventory().getSize()==54?CubeType.VACUUM:CubeType.LARGE; CubeType cub = p.getOpenInventory().getTopInventory().getSize()==9?CubeType.NORMAL:p.getOpenInventory().getTopInventory().getSize()==54?CubeType.VACUUM:CubeType.LARGE;
SoundUtils.playLocalSound(p, Sound.BLOCK_CHEST_CLOSE, 1.0f, 1.0f); SoundUtils.playLocalSound(p, Sound.BLOCK_CHEST_CLOSE, 1.0f, 1.0f);
itemCube_saveConfig(id,itemcube_contents,cub); itemCube_saveConfig(id,itemcube_contents,cub);
itemcube_updates.put(id, itemcube_list);//This Item Cube can be saved.
if (!pd.opened_another_cube) { if (!pd.opened_another_cube) {
ItemCubeWindow.removeAllItemCubeWindows(p); ItemCubeWindow.removeAllItemCubeWindows(p);
GenericFunctions.updateSetItemsInInventory(p.getInventory());
} }
pd.isViewingItemCube=false; pd.isViewingItemCube=false;
} }
@ -4904,6 +5004,44 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
log("Raw Slot Clicked: "+ev.getRawSlot(),5); //5,6,7,8 for gear slots. log("Raw Slot Clicked: "+ev.getRawSlot(),5); //5,6,7,8 for gear slots.
log("Slot Type: "+ev.getSlotType().name(),5); //5,6,7,8 for gear slots. log("Slot Type: "+ev.getSlotType().name(),5); //5,6,7,8 for gear slots.
////////////////////////DO NOT PUT ANYTHING HERE! DEATH STRUCTURE NEEDS TO OVERRIDE ALL BEHAVIORS.
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;
}
////////////////////////////////////////////////////
//////////////////////////////
/////////////////HANDLE DEATH STRUCTURE UP HERE. DO NOT PUT OTHER THINGS ABOVE THIS LINE.
if (!Christmas.runInventoryClickEvent(ev)) { if (!Christmas.runInventoryClickEvent(ev)) {
return; return;
} }
@ -4957,6 +5095,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} else { } else {
ev.setCursor(new ItemStack(Material.AIR)); ev.setCursor(new ItemStack(Material.AIR));
} }
GenericFunctions.UpdateItemLore(ev.getCurrentItem());
((Player)ev.getWhoClicked()).updateInventory(); ((Player)ev.getWhoClicked()).updateInventory();
ev.setCancelled(true); ev.setCancelled(true);
return; return;
@ -4976,37 +5115,6 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
return; 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 (ev.getClick()==ClickType.RIGHT && Artifact.isMalleableBase(ev.getCurrentItem())) {
if (MalleableBaseQuest.getStatus(ev.getCurrentItem())==QuestStatus.UNFORMED) { if (MalleableBaseQuest.getStatus(ev.getCurrentItem())==QuestStatus.UNFORMED) {
StartMalleableBaseQuest((Player)ev.getWhoClicked()); StartMalleableBaseQuest((Player)ev.getWhoClicked());
@ -5131,6 +5239,26 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
//ItemCubeWindow.removeAllItemCubeWindows((Player)ev.getWhoClicked()); //ItemCubeWindow.removeAllItemCubeWindows((Player)ev.getWhoClicked());
Player p = (Player)ev.getWhoClicked(); Player p = (Player)ev.getWhoClicked();
pd = PlayerStructure.GetPlayerStructure(p); pd = PlayerStructure.GetPlayerStructure(p);
List<ItemStack> itemcube_list = new ArrayList<ItemStack>();
for (int i=0;i<ev.getWhoClicked().getOpenInventory().getTopInventory().getSize();i++) {
if (ItemUtils.isValidItem(ev.getWhoClicked().getOpenInventory().getTopInventory().getItem(i))) {
boolean found=false;
for (int j=0;j<itemcube_list.size();j++) {
if (itemcube_list.get(j).isSimilar(ev.getWhoClicked().getOpenInventory().getTopInventory().getItem(i))) {
ItemStack newitem = itemcube_list.get(j).clone();
newitem.setAmount(newitem.getAmount()+ev.getWhoClicked().getOpenInventory().getTopInventory().getItem(i).getAmount());
itemcube_list.set(j, newitem);
found=true;
break;
}
}
if (!found) {
itemcube_list.add(ev.getWhoClicked().getOpenInventory().getTopInventory().getItem(i));
}
}
}
itemcube_updates.put(Integer.parseInt(ev.getInventory().getTitle().split("#")[1]), itemcube_list);//This Item Cube can be saved.
GenericFunctions.updateSetItemsInInventory(p.getInventory());
// //
pd.opened_another_cube=true; pd.opened_another_cube=true;
if (pd.itemcubelist.size()==0) {ev.getWhoClicked().closeInventory();} if (pd.itemcubelist.size()==0) {ev.getWhoClicked().closeInventory();}
@ -5298,10 +5426,28 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
log("Cursor should be air.",5); log("Cursor should be air.",5);
} }
List<ItemStack> itemslist = new ArrayList<ItemStack>(); List<ItemStack> itemslist = new ArrayList<ItemStack>();
List<ItemStack> itemcube_list = new ArrayList<ItemStack>();
for (int i=0;i<virtualinventory.getSize();i++) { for (int i=0;i<virtualinventory.getSize();i++) {
itemslist.add(virtualinventory.getItem(i)); itemslist.add(virtualinventory.getItem(i));
if (ItemUtils.isValidItem(virtualinventory.getItem(i))) {
boolean found=false;
for (int j=0;j<itemcube_list.size();j++) {
if (itemcube_list.get(j).isSimilar(virtualinventory.getItem(i))) {
ItemStack newitem = itemcube_list.get(j).clone();
newitem.setAmount(newitem.getAmount()+virtualinventory.getItem(i).getAmount());
itemcube_list.set(j, newitem);
found=true;
break;
}
}
if (!found) {
itemcube_list.add(virtualinventory.getItem(i));
}
}
} }
itemCube_saveConfig(idnumb,itemslist,cub); itemCube_saveConfig(idnumb,itemslist,cub);
itemcube_updates.put(idnumb, itemcube_list);//This Item Cube can be saved.
GenericFunctions.UpdateItemLore(ev.getCurrentItem());
return; return;
} else { } else {
//Well, we're already in here, I don't know why they didn't just use the //Well, we're already in here, I don't know why they didn't just use the
@ -5317,10 +5463,28 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ev.setCursor(new ItemStack(Material.AIR)); ev.setCursor(new ItemStack(Material.AIR));
} }
List<ItemStack> itemslist = new ArrayList<ItemStack>(); List<ItemStack> itemslist = new ArrayList<ItemStack>();
List<ItemStack> itemcube_list = new ArrayList<ItemStack>();
for (int i=0;i<ev.getWhoClicked().getOpenInventory().getTopInventory().getSize();i++) { for (int i=0;i<ev.getWhoClicked().getOpenInventory().getTopInventory().getSize();i++) {
itemslist.add(ev.getWhoClicked().getOpenInventory().getTopInventory().getItem(i)); itemslist.add(ev.getWhoClicked().getOpenInventory().getTopInventory().getItem(i));
if (ItemUtils.isValidItem(ev.getWhoClicked().getOpenInventory().getTopInventory().getItem(i))) {
boolean found=false;
for (int j=0;j<itemcube_list.size();j++) {
if (itemcube_list.get(j).isSimilar(ev.getWhoClicked().getOpenInventory().getTopInventory().getItem(i))) {
ItemStack newitem = itemcube_list.get(j).clone();
newitem.setAmount(newitem.getAmount()+ev.getWhoClicked().getOpenInventory().getTopInventory().getItem(i).getAmount());
itemcube_list.set(j, newitem);
found=true;
break;
}
}
if (!found) {
itemcube_list.add(ev.getWhoClicked().getOpenInventory().getTopInventory().getItem(i));
}
}
} }
itemCube_saveConfig(idnumb,itemslist); itemCube_saveConfig(idnumb,itemslist);
itemcube_updates.put(idnumb, itemcube_list);//This Item Cube can be saved.
GenericFunctions.UpdateItemLore(ev.getCurrentItem());
return; return;
} }
} }
@ -8105,6 +8269,21 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
} }
if (ItemUtils.isValidLoreItem(ev.getInventory().getResult())) {
for (ItemStack item : ev.getInventory()) {
if (ItemUtils.isValidItem(item) && aPlugin.API.isMoverWandChest(item)) {
ItemStack[] items = aPlugin.API.readMoverWandChestContents(item, false);
ItemStack itemcube = ev.getInventory().getResult().clone();
ItemUtils.addLore(itemcube, ChatColor.WHITE+"Contents:");
for (ItemStack it : items) {
ItemUtils.addLore(itemcube, ChatColor.GRAY+" - "+GenericFunctions.UserFriendlyMaterialName(it)+(it.getAmount()>1?ChatColor.YELLOW+" x"+it.getAmount():""));
}
ev.getInventory().setResult(itemcube);
return;
}
}
}
//This could be our duplication recipe... //This could be our duplication recipe...
if (CustomRecipe.ENDER_ITEM_CUBE_DUPLICATE.isSameRecipe(ev.getRecipe().getResult())) { if (CustomRecipe.ENDER_ITEM_CUBE_DUPLICATE.isSameRecipe(ev.getRecipe().getResult())) {
CustomRecipe.ENDER_ITEM_CUBE_DUPLICATE.ValidateRecipe(ev); CustomRecipe.ENDER_ITEM_CUBE_DUPLICATE.ValidateRecipe(ev);
@ -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; boolean isslayer = PlayerMode.getPlayerMode(p)==PlayerMode.SLAYER;
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
@ -8998,10 +9178,13 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
public static void setPlayerMaxHealth(Player p, Double ratio) { public static void setPlayerMaxHealth(Player p, Double ratio) {
//Determine player max HP based on armor being worn. //Determine player max HP based on armor being worn.
if (EquipmentUpdated(p)) {
TwosideKeeper.log("Equipment updated. Checking health...", 5);
double hp=10; //Get the base max health. double hp=10; //Get the base max health.
//Get all equips. //Get all equips.
ItemStack[] equipment = {p.getInventory().getHelmet(),p.getInventory().getChestplate(),p.getInventory().getLeggings(),p.getInventory().getBoots()}; ItemStack[] equipment = {p.getInventory().getHelmet(),p.getInventory().getChestplate(),p.getInventory().getLeggings(),p.getInventory().getBoots()};
double maxdeduction=1; double maxdeduction=1;
long equiplooptime = System.nanoTime();
for (ItemStack equip : equipment) { for (ItemStack equip : equipment) {
if (equip!=null) { if (equip!=null) {
boolean is_block_form=false; boolean is_block_form=false;
@ -9015,6 +9198,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
hp += dmgval; hp += dmgval;
}*/ }*/
} else { } else {
long time = System.nanoTime();
if (equip.hasItemMeta() && if (equip.hasItemMeta() &&
equip.getItemMeta().hasLore()) { equip.getItemMeta().hasLore()) {
for (int j=0;j<equip.getItemMeta().getLore().size();j++) { for (int j=0;j<equip.getItemMeta().getLore().size();j++) {
@ -9025,6 +9209,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
} }
} }
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Is Block Form Check", (int)(System.nanoTime()-time));time = System.nanoTime();
if (equip.getType().toString().contains("LEATHER")) { if (equip.getType().toString().contains("LEATHER")) {
//This is a leather piece. //This is a leather piece.
hp+=ARMOR_LEATHER_HP; hp+=ARMOR_LEATHER_HP;
@ -9038,42 +9223,57 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
//This is a diamond piece. //This is a diamond piece.
hp+=(is_block_form)?ARMOR_DIAMOND2_HP:ARMOR_DIAMOND_HP; 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 (GenericFunctions.isArtifactEquip(equip)) { if (GenericFunctions.isArtifactEquip(equip)) {
log("Add in "+GenericFunctions.getAbilityValue(ArtifactAbility.HEALTH, equip),5); //log("Add in "+GenericFunctions.getAbilityValue(ArtifactAbility.HEALTH, equip),5);
if (PlayerMode.getPlayerMode(p)==PlayerMode.RANGER) { if (PlayerMode.getPlayerMode(p)==PlayerMode.RANGER) {
long time = System.nanoTime();
hp += (double)GenericFunctions.getAbilityValue(ArtifactAbility.HEALTH, equip)/2; hp += (double)GenericFunctions.getAbilityValue(ArtifactAbility.HEALTH, equip)/2;
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Increase Health for Ranger Armor", (int)(System.nanoTime()-time));time = System.nanoTime();
} else { } else {
long time = System.nanoTime();
hp += (double)GenericFunctions.getAbilityValue(ArtifactAbility.HEALTH, equip); 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)) { if (ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, equip)) {
maxdeduction /= ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, equip)?2:1; maxdeduction /= ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, equip)?2:1;
} }
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Decrease Health based on Greed", (int)(System.nanoTime()-time));time = System.nanoTime();
} }
} }
} }
TwosideKeeper.HeartbeatLogger.AddEntry("----]> Equipment Check", (int)(System.nanoTime()-equiplooptime));
long time = System.nanoTime();
//Check the hotbar for set equips. //Check the hotbar for set equips.
hp+=ItemSet.GetTotalBaseAmount(GenericFunctions.getBaubles(p), p, ItemSet.GLADOMAIN); 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); log("Health is now "+hp,5);
if (ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, p.getEquipment().getItemInMainHand())) { if (ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, p.getEquipment().getItemInMainHand())) {
maxdeduction /= ArtifactAbility.containsEnchantment(ArtifactAbility.GREED, p.getEquipment().getItemInMainHand())?2:1; 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); log("maxdeduction is "+maxdeduction,5);
if (PlayerMode.isDefender(p)) { if (PlayerMode.isDefender(p)) {
hp+=10; hp+=10;
GenericFunctions.logAndApplyPotionEffectToEntity(PotionEffectType.REGENERATION,60,(p.isBlocking())?3:1,p,false); 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)) { if (PlayerMode.isBarbarian(p)) {
double red = 1-CustomDamage.CalculateDamageReduction(1,p,null); double red = 1-CustomDamage.CalculateDamageReduction(1,p,null);
hp+=(red*2)*100; 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); 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); 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)) { if (p.hasPotionEffect(PotionEffectType.ABSORPTION)) {
@ -9085,16 +9285,27 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
}*/ }*/
hp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getEquipment(p), p, ItemSet.ALIKAHN, 2, 2)+ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getEquipment(p), p, ItemSet.ALIKAHN, 3, 3); hp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getEquipment(p), p, ItemSet.ALIKAHN, 2, 2)+ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getEquipment(p), p, ItemSet.ALIKAHN, 3, 3);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Alikahn HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
hp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(GenericFunctions.getEquipment(p), p, ItemSet.COMET, 2, 2); 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); 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); 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); 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); 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); 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); 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); 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); 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); 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)+ /*hp+=ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.ALIKAHN, 4, 4)+
ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.DARNYS, 4, 4)+ ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.DARNYS, 4, 4)+
ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.LORASAADI, 4, 4)+ ItemSet.TotalBaseAmountBasedOnSetBonusCount(p, ItemSet.LORASAADI, 4, 4)+
@ -9103,6 +9314,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if (PlayerMode.getPlayerMode(p)==PlayerMode.NORMAL) { if (PlayerMode.getPlayerMode(p)==PlayerMode.NORMAL) {
hp+=10; hp+=10;
} }
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Adventurer Mode HP Calculation", (int)(System.nanoTime()-time));time = System.nanoTime();
hp*=maxdeduction; hp*=maxdeduction;
@ -9111,6 +9323,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
p.setHealth(hp); p.setHealth(hp);
} }
p.setMaxHealth(hp); p.setMaxHealth(hp);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Reset Health", (int)(System.nanoTime()-time));time = System.nanoTime();
if (!p.isDead()) { if (!p.isDead()) {
if (ratio==null) { if (ratio==null) {
p.setHealth(p.getHealth()); p.setHealth(p.getHealth());
@ -9119,6 +9332,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
p.setHealth(ratio*p.getMaxHealth()); p.setHealth(ratio*p.getMaxHealth());
} }
} }
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Set Health Ratio", (int)(System.nanoTime()-time));time = System.nanoTime();
if (PlayerMode.getPlayerMode(p)==PlayerMode.SLAYER) { if (PlayerMode.getPlayerMode(p)==PlayerMode.SLAYER) {
double slayermodehp = PlayerStructure.GetPlayerStructure(p).slayermodehp; double slayermodehp = PlayerStructure.GetPlayerStructure(p).slayermodehp;
if (ratio==null) { if (ratio==null) {
@ -9130,12 +9344,54 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
p.setHealth(slayermodehp); 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.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(hp);
p.setHealthScaled(false); p.setHealthScaled(false);
TwosideKeeper.HeartbeatLogger.AddEntry("----====]> Final Fix", (int)(System.nanoTime()-time));time = System.nanoTime();
}
} }
private static boolean EquipmentUpdated(Player p) {
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
//Get all equipment.
List<ItemStack> 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<pd.equipmentset.size();i++) {
if (ItemUtils.isValidItem(pd.equipmentset.get(i)) &&
!pd.equipmentset.get(i).isSimilar(newequips.get(i))) {
TwosideKeeper.log(pd.equipmentset.get(i).toString()+" is different from "+newequips.get(i).toString(), 5);
matches=false;
}
}
pd.equipmentset.clear();
pd.equipmentset.addAll(newequips);
return !matches;
}
}
public static List<ItemStack> UpdateEquipmentSet(Player p, PlayerStructure pd) {
List<ItemStack> equips = new ArrayList<ItemStack>();
for (ItemStack item : GenericFunctions.getEquipment(p, true)) {
if (ItemUtils.isValidItem(item)) {
equips.add(setTo0Durability(item.clone()));
}
}
return equips;
}
private static ItemStack setTo0Durability(ItemStack item) {
if (ItemUtils.isValidItem(item)) {
item.setDurability((short)0);
return item;
}
return null;
}
public static void updateTitle(final Player p, boolean headshot, boolean preemptive) { public static void updateTitle(final Player p, boolean headshot, boolean preemptive) {
if (preemptive) { if (preemptive) {
updateTitle(p,ChatColor.BLUE+"!"); updateTitle(p,ChatColor.BLUE+"!");