mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-11-24 02:56:02 +01:00
Added an option to specify what shift does
This commit is contained in:
parent
20f9599c66
commit
a3654ea031
@ -23,6 +23,9 @@ public class Properties {
|
||||
@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_EVERYTHING turned on? (ALL/BUY/SELL)")
|
||||
public static String SHIFT_ALLOWS = "ALL";
|
||||
|
||||
@ConfigurationComment("Can shop's chest be opened by owner with right-clicking a shop's sign?")
|
||||
public static boolean ALLOW_SIGN_CHEST_OPEN = true;
|
||||
|
||||
|
@ -137,7 +137,7 @@ public class PlayerInteract implements Listener {
|
||||
amount = 1;
|
||||
}
|
||||
|
||||
if (Properties.SHIFT_SELLS_EVERYTHING && player.isSneaking() && price != PriceUtil.NO_PRICE) {
|
||||
if (Properties.SHIFT_SELLS_EVERYTHING && player.isSneaking() && price != PriceUtil.NO_PRICE && isAllowedForShift(action == buy)) {
|
||||
int newAmount = getItemAmount(item, ownerInventory, player, action);
|
||||
if (newAmount > 0) {
|
||||
price = (price / amount) * newAmount;
|
||||
@ -153,6 +153,16 @@ public class PlayerInteract implements Listener {
|
||||
return new PreTransactionEvent(ownerInventory, player.getInventory(), items, price, player, owner, sign, transactionType);
|
||||
}
|
||||
|
||||
private static boolean isAllowedForShift(boolean buyTransaction) {
|
||||
String allowed = Properties.SHIFT_ALLOWS;
|
||||
|
||||
if (allowed.equalsIgnoreCase("ALL")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return allowed.equalsIgnoreCase(buyTransaction ? "BUY" : "SELL");
|
||||
}
|
||||
|
||||
private static int getItemAmount(ItemStack item, Inventory inventory, Player player, Action action) {
|
||||
Action buy = Properties.REVERSE_BUTTONS ? LEFT_CLICK_BLOCK : RIGHT_CLICK_BLOCK;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user