Fix deletion of magic pies when another magic pie is activated.

anvil_rework
sigonasr2 11 years ago
parent 7a2e0f9f74
commit 31a1c0c5a8
  1. 36
      BankEconomyMod/src/me/kaZep/Base/PlayerListener.java

@ -5188,32 +5188,21 @@ public ItemStack getGoodie() {
Bukkit.getLogger().info("We have "+piecount+" pies."); Bukkit.getLogger().info("We have "+piecount+" pies.");
if (ideal_pie!=null && magic_pie!=null && piecount>=pies) { if (ideal_pie!=null && magic_pie!=null && piecount>=pies) {
p.getInventory().remove(magic_pie); p.getInventory().remove(magic_pie);
int deductpies=pies; //Check to see if there are any pies we need to keep for later.
int itemslot=0; List<ItemStack> items = new ArrayList<ItemStack>();
while (deductpies>0 || itemslot<p.getInventory().getSize()) { for (int i=0;i<p.getInventory().getContents().length;i++) {
if (deductpies>0) { if (p.getInventory().getContents()[i].getType()==Material.PUMPKIN_PIE &&
if (p.getInventory().getItem(itemslot).getType()==Material.PUMPKIN_PIE && p.getInventory().getItem(itemslot).getItemMeta().getDisplayName()==null) { p.getInventory().getContents()[i].hasItemMeta() &&
if (p.getInventory().getItem(itemslot).getAmount()>1) { p.getInventory().getContents()[i].getItemMeta().getLore()!=null) {
p.getInventory().remove(p.getInventory().getItem(itemslot)); //This is a special pie. Must keep.
deductpies-=p.getInventory().getItem(itemslot).getAmount(); items.add(p.getInventory().getContents()[i]);
} else {
p.getInventory().remove(p.getInventory().getItem(itemslot));
deductpies-=1;
}
itemslot++;
} else {
itemslot++;
}
} else {
itemslot++;
} }
} }
/*
for (int i=0;i<pies;i++) { for (int i=0;i<pies;i++) {
p.getInventory().remove(Material.PUMPKIN_PIE); p.getInventory().remove(Material.PUMPKIN_PIE);
//Remove the pies. Remove the magic pie. //Remove the pies. Remove the magic pie.
}*/ }
/*
int amountleft = piecount-pies; int amountleft = piecount-pies;
while (amountleft>0) { while (amountleft>0) {
if (amountleft>=64) { if (amountleft>=64) {
@ -5223,7 +5212,10 @@ public ItemStack getGoodie() {
p.getInventory().addItem(new ItemStack(Material.PUMPKIN_PIE,1)); p.getInventory().addItem(new ItemStack(Material.PUMPKIN_PIE,1));
amountleft--; amountleft--;
} }
}*/ }
for (int i=0;i<items.size();i++) {
p.getInventory().addItem(items.get(i));
}
//Give a legendary armor/weapon here. //Give a legendary armor/weapon here.
//Bukkit.getLogger().info("LEGENDARY!"); //Bukkit.getLogger().info("LEGENDARY!");
giveLegendaryItem(p); giveLegendaryItem(p);

Loading…
Cancel
Save