mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 11:44:19 +01:00
Server administrators can now specify custom aliases in bukkit.yml which override any aliases set by plugins.
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
dc11d556ba
commit
b02e6095bd
3 changed files with 33 additions and 0 deletions
|
@ -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<String, String> getCommandAliases();
|
||||
}
|
||||
|
|
|
@ -150,6 +150,22 @@ public final class SimpleCommandMap implements CommandMap {
|
|||
return knownCommands.get(name.toLowerCase());
|
||||
}
|
||||
|
||||
public void registerServerAliases() {
|
||||
Map<String, String> 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;
|
||||
|
||||
|
|
|
@ -220,6 +220,15 @@ public class ConfigurationNode {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all keys at the root path
|
||||
*
|
||||
* @return List of keys
|
||||
*/
|
||||
public List<String> getKeys() {
|
||||
return new ArrayList<String>(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.
|
||||
|
|
Loading…
Reference in a new issue