diff --git a/com/Acrobot/ChestShop/Events/TransactionEvent.java b/com/Acrobot/ChestShop/Events/TransactionEvent.java index 193ff63..ff0f0f0 100644 --- a/com/Acrobot/ChestShop/Events/TransactionEvent.java +++ b/com/Acrobot/ChestShop/Events/TransactionEvent.java @@ -25,7 +25,7 @@ public class TransactionEvent extends Event { private Type transactionType; - public TransactionEvent(Type transactionType, Container container, Sign sign, Player client, String owner, ItemStack item, int itemAmount, double price) { + public TransactionEvent(Type transactionType, Container container, Sign sign, Player client, String owner, ItemStack item, double price) { this.container = container; this.sign = sign; @@ -33,7 +33,7 @@ public class TransactionEvent extends Event { this.owner = owner; this.item = item; - this.itemAmount = itemAmount; + this.itemAmount = item.getAmount(); this.transactionType = transactionType; this.price = price; diff --git a/com/Acrobot/ChestShop/Shop/Shop.java b/com/Acrobot/ChestShop/Shop/Shop.java index 12d28ea..6409cc6 100644 --- a/com/Acrobot/ChestShop/Shop/Shop.java +++ b/com/Acrobot/ChestShop/Shop/Shop.java @@ -37,7 +37,6 @@ public class Shop { private final Container container; private final String owner; - private int stockAmount; private ItemStack stock; private final Sign sign; @@ -47,7 +46,6 @@ public class Shop { this.owner = sign.getLine(NAME_LINE); this.stock = stock; - this.stockAmount = stock.getAmount(); this.sign = sign; } @@ -89,8 +87,8 @@ public class Shop { if (!partialTransactionAllowed(possiblePartialItemCount)) { return NOT_ENOUGH_MONEY; } else { - price = (price / stockAmount) * possiblePartialItemCount; - stockAmount = possiblePartialItemCount; + price = (price / stock.getAmount()) * possiblePartialItemCount; + stock.setAmount(possiblePartialItemCount); } } @@ -108,8 +106,8 @@ public class Shop { return NOT_ENOUGH_STOCK; } else { - price = (price / stockAmount) * possiblePartialItemCount; - stockAmount = possiblePartialItemCount; + price = (price / stock.getAmount()) * possiblePartialItemCount; + stock.setAmount(possiblePartialItemCount); } } @@ -121,7 +119,7 @@ public class Shop { player.updateInventory(); - TransactionEvent event = new TransactionEvent(BUY, container, sign, player, this.owner, stock, stockAmount, price); + TransactionEvent event = new TransactionEvent(BUY, container, sign, player, this.owner, stock, price); ChestShop.callEvent(event); return null; @@ -148,8 +146,8 @@ public class Shop { if (!partialTransactionAllowed(possiblePartialItemCount)) { return NOT_ENOUGH_MONEY_SHOP; } else { - price = (price / stockAmount) * possiblePartialItemCount; - stockAmount = possiblePartialItemCount; + price = (price / stock.getAmount()) * possiblePartialItemCount; + stock.setAmount(possiblePartialItemCount); } } @@ -159,8 +157,8 @@ public class Shop { if (!partialTransactionAllowed(possiblePartialItemCount)) { return NOT_ENOUGH_ITEMS_TO_SELL; } else { - price = (price / stockAmount) * possiblePartialItemCount; - stockAmount = possiblePartialItemCount; + price = (price / stock.getAmount()) * possiblePartialItemCount; + stock.setAmount(possiblePartialItemCount); } } @@ -176,7 +174,7 @@ public class Shop { InventoryUtil.remove(stock, player.getInventory()); player.updateInventory(); - TransactionEvent event = new TransactionEvent(SELL, container, sign, player, this.owner, stock, stockAmount, price); + TransactionEvent event = new TransactionEvent(SELL, container, sign, player, this.owner, stock, price); ChestShop.callEvent(event); return null; @@ -207,11 +205,11 @@ public class Shop { } private boolean playerHasEnoughItems(Player player) { - return InventoryUtil.getAmount(stock, player.getInventory()) >= stockAmount; + return InventoryUtil.getAmount(stock, player.getInventory()) >= stock.getAmount(); } private int calculateItemAmount(double money, double basePrice) { - return (int) Math.floor(money / (basePrice / stockAmount)); + return (int) Math.floor(money / (basePrice / stock.getAmount())); } private static void sendMessage(Player player, Language message) { diff --git a/plugin.yml b/plugin.yml index 4eef901..9070659 100644 --- a/plugin.yml +++ b/plugin.yml @@ -2,7 +2,7 @@ name: ChestShop main: com.Acrobot.ChestShop.ChestShop -version: 3.43 TEST BUILD +version: 3.44 TEST BUILD #for CButD dev-url: http://dev.bukkit.org/server-mods/chestshop/