diff --git a/paper-api/src/main/java/org/bukkit/Server.java b/paper-api/src/main/java/org/bukkit/Server.java index 3ea7e634df..2a084a180d 100644 --- a/paper-api/src/main/java/org/bukkit/Server.java +++ b/paper-api/src/main/java/org/bukkit/Server.java @@ -6,6 +6,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.Recipe; import java.util.List; +import java.util.Map; import java.util.logging.Logger; import org.bukkit.command.PluginCommand; @@ -263,4 +264,11 @@ public interface Server { * @return True to indicate that the recipe was added. */ public boolean addRecipe(Recipe recipe); + + /** + * Gets a list of command aliases defined in the server properties. + * + * @return Map of aliases to command names + */ + public Map getCommandAliases(); } diff --git a/paper-api/src/main/java/org/bukkit/command/SimpleCommandMap.java b/paper-api/src/main/java/org/bukkit/command/SimpleCommandMap.java index 33568315c7..dfb066afe7 100644 --- a/paper-api/src/main/java/org/bukkit/command/SimpleCommandMap.java +++ b/paper-api/src/main/java/org/bukkit/command/SimpleCommandMap.java @@ -150,6 +150,22 @@ public final class SimpleCommandMap implements CommandMap { return knownCommands.get(name.toLowerCase()); } + public void registerServerAliases() { + Map values = server.getCommandAliases(); + + for (String alias : values.keySet()) { + String target = values.get(alias); + Command command = getCommand(target); + + if (command != null) { + // We register these as commands so they have absolute priority. + knownCommands.put(alias.toLowerCase(), command); + } else { + server.getLogger().warning("Could not register custom alias '" + alias + "' to command '" + target + "' because the command does not exist."); + } + } + } + private static class VersionCommand extends Command { private final Server server; diff --git a/paper-api/src/main/java/org/bukkit/util/config/ConfigurationNode.java b/paper-api/src/main/java/org/bukkit/util/config/ConfigurationNode.java index 79a8932ff7..ae28a23a2e 100644 --- a/paper-api/src/main/java/org/bukkit/util/config/ConfigurationNode.java +++ b/paper-api/src/main/java/org/bukkit/util/config/ConfigurationNode.java @@ -220,6 +220,15 @@ public class ConfigurationNode { } } + /** + * Returns a list of all keys at the root path + * + * @return List of keys + */ + public List getKeys() { + return new ArrayList(root.keySet()); + } + /** * Gets a list of objects at a location. If the list is not defined, * null will be returned. The node must be an actual list.