This commit is contained in:
Justin M 2024-02-03 17:47:20 +01:00 committed by GitHub
commit 16acc1f3eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 38 additions and 1 deletions

View File

@ -405,6 +405,7 @@ public interface ISettings extends IConf {
boolean isUpdateCheckEnabled();
boolean showZeroBaltop();
BigDecimal getMultiplier(final User user);
int getMaxItemLore();

View File

@ -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);
}

View File

@ -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"));

View File

@ -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 | #