From f1d9cda5ebf08289c41ca776ca8c6089c596e620 Mon Sep 17 00:00:00 2001 From: Ali Moghnieh Date: Tue, 26 Jul 2016 12:25:20 +0100 Subject: [PATCH] Create allow-bulk-buy-sell config option. Resolves #765. --- Essentials/src/com/earth2me/essentials/ISettings.java | 2 ++ Essentials/src/com/earth2me/essentials/Settings.java | 5 +++++ Essentials/src/com/earth2me/essentials/signs/SignBuy.java | 2 +- Essentials/src/com/earth2me/essentials/signs/SignSell.java | 2 +- Essentials/src/config.yml | 4 ++++ 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index f7daaca90..e55779b3c 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -267,4 +267,6 @@ public interface ISettings extends IConf { List getUnprotectedSignNames(); boolean isPastebinCreateKit(); + + boolean isAllowBulkBuySell(); } diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index 02e78ccc2..626dd8421 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -1359,4 +1359,9 @@ public class Settings implements net.ess3.api.ISettings { public boolean isPastebinCreateKit() { return config.getBoolean("pastebin-createkit", true); } + + @Override + public boolean isAllowBulkBuySell() { + return config.getBoolean("allow-bulk-buy-sell", false); + } } diff --git a/Essentials/src/com/earth2me/essentials/signs/SignBuy.java b/Essentials/src/com/earth2me/essentials/signs/SignBuy.java index 48e65849f..2900e72ff 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignBuy.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignBuy.java @@ -29,7 +29,7 @@ public class SignBuy extends EssentialsSign { Trade charge = getTrade(sign, 3, ess); // Check if the player is trying to buy in bulk. - if (player.getBase().isSneaking()) { + if (ess.getSettings().isAllowBulkBuySell() && player.getBase().isSneaking()) { ItemStack heldItem = player.getItemInHand(); if (items.getItemStack().isSimilar(heldItem)) { int initialItemAmount = items.getItemStack().getAmount(); diff --git a/Essentials/src/com/earth2me/essentials/signs/SignSell.java b/Essentials/src/com/earth2me/essentials/signs/SignSell.java index ff8353793..8723b1271 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignSell.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignSell.java @@ -30,7 +30,7 @@ public class SignSell extends EssentialsSign { Trade money = getTrade(sign, 3, ess); // Check if the player is trying to sell in bulk. - if (player.getBase().isSneaking()) { + if (ess.getSettings().isAllowBulkBuySell() && player.getBase().isSneaking()) { ItemStack heldItem = player.getItemInHand(); if (charge.getItemStack().isSimilar(heldItem)) { int initialItemAmount = charge.getItemStack().getAmount(); diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index d825dc5a6..3c9af3bf3 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -522,6 +522,10 @@ npcs-in-balance-ranking: false # WARNING: If this is false, the config comments WILL be removed and it won't look the same as it does now. pastebin-createkit: true +# Allow bulk buying and selling signs when the player is sneaking. +# This is useful when a sign sells or buys one item at a time and the player wants to sell a bunch at once. +allow-bulk-buy-sell: true + ############################################################ # +------------------------------------------------------+ # # | EssentialsHome | #