mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-22 00:58:50 +01:00
Added sell multipliers (#4770)
Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
This commit is contained in:
parent
424816ef51
commit
e1091d887d
@ -418,6 +418,8 @@ public interface ISettings extends IConf {
|
||||
|
||||
boolean showZeroBaltop();
|
||||
|
||||
BigDecimal getMultiplier(final User user);
|
||||
|
||||
int getMaxItemLore();
|
||||
|
||||
Tag getPrimaryColor();
|
||||
|
@ -149,6 +149,8 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
private Map<String, String> worldAliases;
|
||||
private Tag primaryColor = DEFAULT_PRIMARY_COLOR;
|
||||
private Tag secondaryColor = DEFAULT_SECONDARY_COLOR;
|
||||
private Set<String> multiplierPerms;
|
||||
private BigDecimal defaultMultiplier;
|
||||
|
||||
public Settings(final IEssentials ess) {
|
||||
this.ess = ess;
|
||||
@ -921,6 +923,8 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
worldAliases = _getWorldAliases();
|
||||
primaryColor = _getPrimaryColor();
|
||||
secondaryColor = _getSecondaryColor();
|
||||
multiplierPerms = _getMultiplierPerms();
|
||||
defaultMultiplier = _getDefaultMultiplier();
|
||||
|
||||
reloadCount.incrementAndGet();
|
||||
}
|
||||
@ -2090,6 +2094,33 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
}
|
||||
|
||||
@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<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);
|
||||
}
|
||||
|
@ -93,7 +93,8 @@ 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 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");
|
||||
|
@ -41,6 +41,7 @@ public class SignSell extends EssentialsSign {
|
||||
//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);
|
||||
}
|
||||
}
|
||||
|
@ -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.<multiplier-rank>
|
||||
sell-multipliers:
|
||||
default: 1.0
|
||||
double: 2.0
|
||||
triple: 3.0
|
||||
|
||||
############################################################
|
||||
# +------------------------------------------------------+ #
|
||||
# | Help | #
|
||||
|
Loading…
Reference in New Issue
Block a user