diff --git a/src/main/java/com/Acrobot/ChestShop/Configuration/Properties.java b/src/main/java/com/Acrobot/ChestShop/Configuration/Properties.java index d5c8126..b1a83d0 100644 --- a/src/main/java/com/Acrobot/ChestShop/Configuration/Properties.java +++ b/src/main/java/com/Acrobot/ChestShop/Configuration/Properties.java @@ -130,6 +130,9 @@ public class Properties { @ConfigurationComment("If true, people will be able to buy/sell in 64 stacks while holding the crouch button.") public static boolean SHIFT_SELLS_IN_STACKS = false; + @ConfigurationComment("If true, people will be able to sell/buy everything available of the same type.") + public static boolean SHIFT_SELLS_EVERYTHING = false; + @ConfigurationComment("What can you do by clicking shift with SHIFT_SELLS_IN_STACKS turned on? (ALL/BUY/SELL)") public static String SHIFT_ALLOWS = "ALL"; diff --git a/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerInteract.java b/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerInteract.java index 39c267f..159dadc 100644 --- a/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerInteract.java +++ b/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerInteract.java @@ -203,6 +203,20 @@ public class PlayerInteract implements Listener { price = price.divide(BigDecimal.valueOf(amount), MathContext.DECIMAL128).multiply(BigDecimal.valueOf(newAmount)).setScale(Properties.PRICE_PRECISION, BigDecimal.ROUND_HALF_UP); amount = newAmount; } + } else if (Properties.SHIFT_SELLS_EVERYTHING && player.isSneaking() && !price.equals(PriceUtil.NO_PRICE) && isAllowedForShift(action == buy)) { + if (action != buy) { + int newAmount = InventoryUtil.getAmount(item, player.getInventory()); + if (newAmount > 0) { + price = price.divide(BigDecimal.valueOf(amount), MathContext.DECIMAL128).multiply(BigDecimal.valueOf(newAmount)).setScale(Properties.PRICE_PRECISION, BigDecimal.ROUND_HALF_UP); + amount = newAmount; + } + } else if (!adminShop && ownerInventory != null) { + int newAmount = InventoryUtil.getAmount(item, ownerInventory); + if (newAmount > 0) { + price = price.divide(BigDecimal.valueOf(amount), MathContext.DECIMAL128).multiply(BigDecimal.valueOf(newAmount)).setScale(Properties.PRICE_PRECISION, BigDecimal.ROUND_HALF_UP); + amount = newAmount; + } + } } item.setAmount(amount);