Admin cmds, perms and descriptions for all cmds +

Additonal stuff: Fixed + refactored help command. Removed 'Usage: ' from all commands. Created 'player.hasPermission(permission)' function. Created default for Usage annotation. Created hashmap version of 'getHandlers' and renamed the original to getHandlersAsList()
This commit is contained in:
Benjamin Elsdon
2022-04-19 18:17:19 +08:00
parent c2403d8d88
commit ceaedca209
5 changed files with 202 additions and 51 deletions

View File

@@ -68,10 +68,12 @@ public final class CommandMap {
* Returns a list of all registered commands.
* @return All command handlers as a list.
*/
public List<CommandHandler> getHandlers() {
public List<CommandHandler> getHandlersAsList() {
return new LinkedList<>(this.commands.values());
}
public HashMap<String, CommandHandler> getHandlers() { return new LinkedHashMap<>(this.commands); }
/**
* Returns a handler by label/alias.
* @param label The command label.
@@ -111,8 +113,7 @@ public final class CommandMap {
if(player != null) {
String permissionNode = this.annotations.get(label).permission();
Account account = player.getAccount();
List<String> permissions = account.getPermissions();
if(!permissions.contains("*") && !permissions.contains(permissionNode)) {
if(permissionNode != "" && !account.hasPermission(permissionNode)) {
CommandHandler.sendMessage(player, "You do not have permission to run this command."); return;
}
}