mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-31 21:48:31 +01:00
Cache overridden-commands and player-commands in Settings (#4345)
This commit is contained in:
parent
c020526b1e
commit
eed73e3157
@ -48,8 +48,8 @@ import static com.earth2me.essentials.I18n.tl;
|
|||||||
|
|
||||||
public class Settings implements net.ess3.api.ISettings {
|
public class Settings implements net.ess3.api.ISettings {
|
||||||
private static final Logger logger = Logger.getLogger("Essentials");
|
private static final Logger logger = Logger.getLogger("Essentials");
|
||||||
private static final BigDecimal MAXMONEY = new BigDecimal("10000000000000");
|
private static final BigDecimal DEFAULT_MAX_MONEY = new BigDecimal("10000000000000");
|
||||||
private static final BigDecimal MINMONEY = new BigDecimal("-10000000000000");
|
private static final BigDecimal DEFAULT_MIN_MONEY = new BigDecimal("-10000000000000");
|
||||||
private final transient EssentialsConfiguration config;
|
private final transient EssentialsConfiguration config;
|
||||||
private final transient IEssentials ess;
|
private final transient IEssentials ess;
|
||||||
private final transient AtomicInteger reloadCount = new AtomicInteger(0);
|
private final transient AtomicInteger reloadCount = new AtomicInteger(0);
|
||||||
@ -62,6 +62,8 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
private boolean teleportSafety;
|
private boolean teleportSafety;
|
||||||
private boolean forceDisableTeleportSafety;
|
private boolean forceDisableTeleportSafety;
|
||||||
private Set<String> disabledCommands = new HashSet<>();
|
private Set<String> disabledCommands = new HashSet<>();
|
||||||
|
private List<String> overriddenCommands = Collections.emptyList();
|
||||||
|
private List<String> playerCommands = Collections.emptyList();
|
||||||
private final transient Map<String, Command> disabledBukkitCommands = new HashMap<>();
|
private final transient Map<String, Command> disabledBukkitCommands = new HashMap<>();
|
||||||
private Map<String, BigDecimal> commandCosts;
|
private Map<String, BigDecimal> commandCosts;
|
||||||
private Set<String> socialSpyCommands = new HashSet<>();
|
private Set<String> socialSpyCommands = new HashSet<>();
|
||||||
@ -76,8 +78,8 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
private boolean configDebug = false;
|
private boolean configDebug = false;
|
||||||
// #easteregg
|
// #easteregg
|
||||||
private boolean economyDisabled = false;
|
private boolean economyDisabled = false;
|
||||||
private BigDecimal maxMoney = MAXMONEY;
|
private BigDecimal maxMoney = DEFAULT_MAX_MONEY;
|
||||||
private BigDecimal minMoney = MINMONEY;
|
private BigDecimal minMoney = DEFAULT_MIN_MONEY;
|
||||||
private boolean economyLog = false;
|
private boolean economyLog = false;
|
||||||
// #easteregg
|
// #easteregg
|
||||||
private boolean economyLogUpdate = false;
|
private boolean economyLogUpdate = false;
|
||||||
@ -317,9 +319,13 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
return disCommands;
|
return disCommands;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<String> _getPlayerCommands() {
|
||||||
|
return config.getList("player-commands", String.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPlayerCommand(final String label) {
|
public boolean isPlayerCommand(final String label) {
|
||||||
for (final String c : config.getList("player-commands", String.class)) {
|
for (final String c : playerCommands) {
|
||||||
if (!c.equalsIgnoreCase(label)) {
|
if (!c.equalsIgnoreCase(label)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -328,9 +334,13 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<String> _getOverriddenCommands() {
|
||||||
|
return config.getList("overridden-commands", String.class);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCommandOverridden(final String name) {
|
public boolean isCommandOverridden(final String name) {
|
||||||
for (final String c : config.getList("overridden-commands", String.class)) {
|
for (final String c : overriddenCommands) {
|
||||||
if (!c.equalsIgnoreCase(name)) {
|
if (!c.equalsIgnoreCase(name)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -643,6 +653,8 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
chatFormats.clear();
|
chatFormats.clear();
|
||||||
changeDisplayName = _changeDisplayName();
|
changeDisplayName = _changeDisplayName();
|
||||||
disabledCommands = _getDisabledCommands();
|
disabledCommands = _getDisabledCommands();
|
||||||
|
overriddenCommands = _getOverriddenCommands();
|
||||||
|
playerCommands = _getPlayerCommands();
|
||||||
|
|
||||||
// This will be late loaded
|
// This will be late loaded
|
||||||
if (ess.getKnownCommandsProvider() != null) {
|
if (ess.getKnownCommandsProvider() != null) {
|
||||||
@ -934,7 +946,7 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private BigDecimal _getMaxMoney() {
|
private BigDecimal _getMaxMoney() {
|
||||||
return config.getBigDecimal("max-money", MAXMONEY);
|
return config.getBigDecimal("max-money", DEFAULT_MAX_MONEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -943,7 +955,7 @@ public class Settings implements net.ess3.api.ISettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private BigDecimal _getMinMoney() {
|
private BigDecimal _getMinMoney() {
|
||||||
BigDecimal min = config.getBigDecimal("min-money", MINMONEY);
|
BigDecimal min = config.getBigDecimal("min-money", DEFAULT_MIN_MONEY);
|
||||||
if (min.signum() > 0) {
|
if (min.signum() > 0) {
|
||||||
min = min.negate();
|
min = min.negate();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user