mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2025-01-23 23:31:19 +01:00
Add option to sell/buy all with shift (#320)
This commit is contained in:
parent
f0641abf2e
commit
9f84ca8551
@ -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.")
|
@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;
|
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)")
|
@ConfigurationComment("What can you do by clicking shift with SHIFT_SELLS_IN_STACKS turned on? (ALL/BUY/SELL)")
|
||||||
public static String SHIFT_ALLOWS = "ALL";
|
public static String SHIFT_ALLOWS = "ALL";
|
||||||
|
|
||||||
|
@ -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);
|
price = price.divide(BigDecimal.valueOf(amount), MathContext.DECIMAL128).multiply(BigDecimal.valueOf(newAmount)).setScale(Properties.PRICE_PRECISION, BigDecimal.ROUND_HALF_UP);
|
||||||
amount = newAmount;
|
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);
|
item.setAmount(amount);
|
||||||
|
Loading…
Reference in New Issue
Block a user