Fix disabled-commands not removing aliases (#4399)

Fixes #4383, an issue where only the main command name is disabled instead of the alias specified in `config.yml`.
This commit is contained in:
Josh Roy 2021-08-09 11:59:36 -07:00 committed by GitHub
parent c221e96122
commit 2fa9c6486e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -669,24 +669,25 @@ public class Settings implements net.ess3.api.ISettings {
} }
for (final String command : disabledCommands) { for (final String command : disabledCommands) {
final Command toDisable = ess.getPluginCommand(command); final String effectiveAlias = command.toLowerCase(Locale.ENGLISH);
final Command toDisable = ess.getPluginCommand(effectiveAlias);
if (toDisable != null) { if (toDisable != null) {
if (isDebug()) { if (isDebug()) {
logger.log(Level.INFO, "Attempting removal of " + command); logger.log(Level.INFO, "Attempting removal of " + effectiveAlias);
} }
final Command removed = ess.getKnownCommandsProvider().getKnownCommands().remove(toDisable.getName()); final Command removed = ess.getKnownCommandsProvider().getKnownCommands().remove(effectiveAlias);
if (removed != null) { if (removed != null) {
if (isDebug()) { if (isDebug()) {
logger.log(Level.INFO, "Adding command " + command + " to disabled map!"); logger.log(Level.INFO, "Adding command " + effectiveAlias + " to disabled map!");
} }
disabledBukkitCommands.put(command, removed); disabledBukkitCommands.put(effectiveAlias, removed);
} }
// This is 2 because Settings are reloaded twice in the startup lifecycle // This is 2 because Settings are reloaded twice in the startup lifecycle
if (reloadCount.get() < 2) { if (reloadCount.get() < 2) {
ess.scheduleSyncDelayedTask(() -> _addAlternativeCommand(command, toDisable)); ess.scheduleSyncDelayedTask(() -> _addAlternativeCommand(effectiveAlias, toDisable));
} else { } else {
_addAlternativeCommand(command, toDisable); _addAlternativeCommand(effectiveAlias, toDisable);
} }
mapModified = true; mapModified = true;
} }