diff --git a/Essentials/src/main/java/com/earth2me/essentials/ISettings.java b/Essentials/src/main/java/com/earth2me/essentials/ISettings.java index 81de330641a..eedc49e01db 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/main/java/com/earth2me/essentials/ISettings.java @@ -418,6 +418,8 @@ public interface ISettings extends IConf { boolean showZeroBaltop(); + BigDecimal getMultiplier(final User user); + int getMaxItemLore(); Tag getPrimaryColor(); diff --git a/Essentials/src/main/java/com/earth2me/essentials/Settings.java b/Essentials/src/main/java/com/earth2me/essentials/Settings.java index 908e2ca11f0..f817dca9273 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/Settings.java +++ b/Essentials/src/main/java/com/earth2me/essentials/Settings.java @@ -149,6 +149,8 @@ public class Settings implements net.ess3.api.ISettings { private Map worldAliases; private Tag primaryColor = DEFAULT_PRIMARY_COLOR; private Tag secondaryColor = DEFAULT_SECONDARY_COLOR; + private Set multiplierPerms; + private BigDecimal defaultMultiplier; public Settings(final IEssentials ess) { this.ess = ess; @@ -921,6 +923,8 @@ public void reloadConfig() { worldAliases = _getWorldAliases(); primaryColor = _getPrimaryColor(); secondaryColor = _getSecondaryColor(); + multiplierPerms = _getMultiplierPerms(); + defaultMultiplier = _getDefaultMultiplier(); reloadCount.incrementAndGet(); } @@ -2090,6 +2094,33 @@ public boolean showZeroBaltop() { } @Override + public BigDecimal getMultiplier(final User user) { + BigDecimal multiplier = defaultMultiplier; + if (multiplierPerms == null) { + return defaultMultiplier; + } + + for (final String multiplierPerm : multiplierPerms) { + if (user.isAuthorized("essentials.sell.multiplier." + multiplierPerm)) { + final BigDecimal value = config.getBigDecimal("sell-multipliers." + multiplierPerm, BigDecimal.ZERO); + if (value.compareTo(multiplier) > 0) { + multiplier = value; + } + } + } + + return multiplier; + } + + private BigDecimal _getDefaultMultiplier() { + return config.getBigDecimal("sell-multipliers.default", BigDecimal.ONE); + } + + private Set _getMultiplierPerms() { + final CommentedConfigurationNode section = config.getSection("sell-multipliers"); + return section == null ? null : ConfigurateUtil.getKeys(section); + } + public int getMaxItemLore() { return config.getInt("max-itemlore-lines", 10); } diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandsell.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandsell.java index 4110de1024b..9a9ca1cf603 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandsell.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandsell.java @@ -93,7 +93,8 @@ public void run(final Server server, final User user, final String commandLabel, private BigDecimal sellItem(final User user, final ItemStack is, final String[] args, final boolean isBulkSell) throws Exception { final int amount = ess.getWorth().getAmount(ess, user, is, args, isBulkSell); - final BigDecimal worth = ess.getWorth().getPrice(ess, is); + final BigDecimal originalWorth = ess.getWorth().getPrice(ess, is); + final BigDecimal worth = originalWorth == null ? null : originalWorth.multiply(ess.getSettings().getMultiplier(user)); if (worth == null) { throw new TranslatableException("itemCannotBeSold"); diff --git a/Essentials/src/main/java/com/earth2me/essentials/signs/SignSell.java b/Essentials/src/main/java/com/earth2me/essentials/signs/SignSell.java index 1e1079f2588..5841e2b6ee6 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/signs/SignSell.java +++ b/Essentials/src/main/java/com/earth2me/essentials/signs/SignSell.java @@ -41,6 +41,7 @@ protected boolean onSignInteract(final ISign sign, final User player, final Stri //noinspection BigDecimalMethodWithoutRoundingCalled BigDecimal pricePerSingleItem = chargeAmount.divide(new BigDecimal(initialItemAmount)); pricePerSingleItem = pricePerSingleItem.multiply(new BigDecimal(newItemAmount)); + pricePerSingleItem = pricePerSingleItem.multiply(ess.getSettings().getMultiplier(player)); money = new Trade(pricePerSingleItem, ess); } } diff --git a/Essentials/src/main/resources/config.yml b/Essentials/src/main/resources/config.yml index 96bcb82afe5..f10f9924809 100644 --- a/Essentials/src/main/resources/config.yml +++ b/Essentials/src/main/resources/config.yml @@ -879,6 +879,15 @@ baltop-requirements: # For 1'234,50 use fr-ch #currency-symbol-format-locale: en-US +# Allow players to receive multipliers for items sold with /sell or the sell sign. +# You can set the default multiplier using the 'default' rank below. +# To grant different multipliers to different people, you need to define a 'multiplier-rank' below. +# Create the 'multiplier-rank' below, and give the matching permission: essentials.sell.multiplier. +sell-multipliers: + default: 1.0 + double: 2.0 + triple: 3.0 + ############################################################ # +------------------------------------------------------+ # # | Help | #