Merge 7dd442c73a
into 8234dedb22
This commit is contained in:
commit
16acc1f3eb
|
@ -405,6 +405,7 @@ public interface ISettings extends IConf {
|
|||
boolean isUpdateCheckEnabled();
|
||||
|
||||
boolean showZeroBaltop();
|
||||
BigDecimal getMultiplier(final User user);
|
||||
|
||||
int getMaxItemLore();
|
||||
|
||||
|
|
|
@ -136,6 +136,8 @@ public class Settings implements net.ess3.api.ISettings {
|
|||
private double maxProjectileSpeed;
|
||||
private boolean removeEffectsOnHeal;
|
||||
private Map<String, String> worldAliases;
|
||||
private Set<String> multiplierPerms;
|
||||
private BigDecimal defaultMultiplier;
|
||||
|
||||
public Settings(final IEssentials ess) {
|
||||
this.ess = ess;
|
||||
|
@ -779,6 +781,8 @@ public class Settings implements net.ess3.api.ISettings {
|
|||
bindingItemPolicy = _getBindingItemsPolicy();
|
||||
currencySymbol = _getCurrencySymbol();
|
||||
worldAliases = _getWorldAliases();
|
||||
multiplierPerms = _getMultiplierPerms();
|
||||
defaultMultiplier = _getDefaultMultiplier();
|
||||
|
||||
reloadCount.incrementAndGet();
|
||||
}
|
||||
|
@ -1945,6 +1949,27 @@ public class Settings implements net.ess3.api.ISettings {
|
|||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal getMultiplier(final User user) {
|
||||
BigDecimal multiplier = defaultMultiplier;
|
||||
if (multiplierPerms == null) return defaultMultiplier;
|
||||
for (String multiplierPerm : multiplierPerms) {
|
||||
if (user.isAuthorized("essentials.sell.multiplier." + multiplierPerm)) {
|
||||
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<String> _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);
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ public class Commandsell extends EssentialsCommand {
|
|||
|
||||
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 worth = ess.getWorth().getPrice(ess, is) == null ? null : ess.getWorth().getPrice(ess, is).multiply(ess.getSettings().getMultiplier(user));
|
||||
|
||||
if (worth == null) {
|
||||
throw new Exception(tl("itemCannotBeSold"));
|
||||
|
|
|
@ -854,6 +854,17 @@ show-zero-baltop: true
|
|||
# For 1'234,50 use fr-ch
|
||||
#currency-symbol-format-locale: en-US
|
||||
|
||||
# Settings for /sell multipliers
|
||||
# Give multipliers to players with the permission 'essentials.sell.multiplier.{multiplier}'
|
||||
# example: 'essentials.sell.multiplier.double', 'essentials.sell.multiplier.triple'
|
||||
# You can add as many multipliers as you want.
|
||||
# Use the "default" name to set the default multiplier that everyone has. It defaults to 1 if not set.
|
||||
# If a player has more than one multiplier permission, it will pick the highest one.
|
||||
sell-multipliers:
|
||||
default: 1.0
|
||||
double: 2.0
|
||||
triple: 3.0
|
||||
|
||||
############################################################
|
||||
# +------------------------------------------------------+ #
|
||||
# | Help | #
|
||||
|
|
Loading…
Reference in New Issue