From 9ef6305a0a8fa010ca8a8824a0ba430cf71280a1 Mon Sep 17 00:00:00 2001 From: Acrobot Date: Mon, 25 Jun 2012 17:16:41 +0200 Subject: [PATCH] Fixed a bug in bukkit (which changed ItemStacks in arguments) --- com/Acrobot/ChestShop/Shop/Shop.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/com/Acrobot/ChestShop/Shop/Shop.java b/com/Acrobot/ChestShop/Shop/Shop.java index 6409cc6..e56d9f8 100644 --- a/com/Acrobot/ChestShop/Shop/Shop.java +++ b/com/Acrobot/ChestShop/Shop/Shop.java @@ -43,11 +43,10 @@ public class Shop { public Shop(Container container, ItemStack stock, Sign sign) { this.container = container; - this.owner = sign.getLine(NAME_LINE); - - this.stock = stock; - this.sign = sign; + + this.owner = sign.getLine(NAME_LINE); + this.stock = stock; } public void buyFromPlayer(Player player) { @@ -114,8 +113,8 @@ public class Shop { Economy.add(getOwnerAccount(), price); Economy.subtract(playerName, price); - container.removeItem(stock); - InventoryUtil.add(stock, player.getInventory()); + container.removeItem(stock.clone()); //Bad bukkit! You shouldn't change ItemStacks during the process! + InventoryUtil.add(stock.clone(), player.getInventory()); player.updateInventory(); @@ -131,9 +130,11 @@ public class Shop { if (container == null) { return NO_CHEST_DETECTED; } + if (price == PriceUtil.NO_PRICE) { return NO_SELLING_HERE; } + if (!hasPermission(player, stock.getType(), false)) { return NO_PERMISSION; } @@ -169,9 +170,9 @@ public class Shop { Economy.subtract(ownerAccount, price); Economy.add(player.getName(), price); - container.addItem(stock); + container.addItem(stock.clone()); - InventoryUtil.remove(stock, player.getInventory()); + InventoryUtil.remove(stock.clone(), player.getInventory()); player.updateInventory(); TransactionEvent event = new TransactionEvent(SELL, container, sign, player, this.owner, stock, price);