geforkt von Mirrors/Paper
Clean up alias handling.
There is no need to print a stacktrace when an alias fails, we do not do this for normal commands. We also now give error messages when attempting to register an alias instead of having them just silently not function. By: Travis Watkins <amaranth@ubuntu.com>
Dieser Commit ist enthalten in:
Ursprung
5e5173aeb4
Commit
cd6bf023f6
@ -48,7 +48,6 @@ public class FormattedCommandAlias extends Command {
|
|||||||
} else {
|
} else {
|
||||||
sender.sendMessage(org.bukkit.ChatColor.RED + "An internal error occurred while attempting to perform this command");
|
sender.sendMessage(org.bukkit.ChatColor.RED + "An internal error occurred while attempting to perform this command");
|
||||||
}
|
}
|
||||||
Bukkit.getLogger().log(Level.WARNING, "Failed to parse command alias " + commandLabel + ": " + formatString, throwable);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -257,6 +257,11 @@ public class SimpleCommandMap implements CommandMap {
|
|||||||
Map<String, String[]> values = server.getCommandAliases();
|
Map<String, String[]> values = server.getCommandAliases();
|
||||||
|
|
||||||
for (String alias : values.keySet()) {
|
for (String alias : values.keySet()) {
|
||||||
|
if (alias.contains(":") || alias.contains(" ")) {
|
||||||
|
server.getLogger().warning("Could not register alias " + alias + " because it contains illegal characters");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
String[] commandStrings = values.get(alias);
|
String[] commandStrings = values.get(alias);
|
||||||
List<String> targets = new ArrayList<String>();
|
List<String> targets = new ArrayList<String>();
|
||||||
StringBuilder bad = new StringBuilder();
|
StringBuilder bad = new StringBuilder();
|
||||||
@ -275,16 +280,17 @@ public class SimpleCommandMap implements CommandMap {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bad.length() > 0) {
|
||||||
|
server.getLogger().warning("Could not register alias " + alias + " because it contains commands that do not exist: " + bad);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// We register these as commands so they have absolute priority.
|
// We register these as commands so they have absolute priority.
|
||||||
if (targets.size() > 0) {
|
if (targets.size() > 0) {
|
||||||
knownCommands.put(alias.toLowerCase(), new FormattedCommandAlias(alias.toLowerCase(), targets.toArray(new String[targets.size()])));
|
knownCommands.put(alias.toLowerCase(), new FormattedCommandAlias(alias.toLowerCase(), targets.toArray(new String[targets.size()])));
|
||||||
} else {
|
} else {
|
||||||
knownCommands.remove(alias.toLowerCase());
|
knownCommands.remove(alias.toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bad.length() > 0) {
|
|
||||||
server.getLogger().warning("The following command(s) could not be aliased under '" + alias + "' because they do not exist: " + bad);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren