From 3b69b2df4d7eba9a0e6e200650edf7c3b534f158 Mon Sep 17 00:00:00 2001 From: William Date: Wed, 17 Aug 2022 23:19:39 +0100 Subject: [PATCH] Manually register aliases --- .../huskhomes/command/BukkitCommand.java | 2 -- bukkit/src/main/resources/plugin.yml | 4 ++++ .../huskhomes/command/CommandBase.java | 17 +++++++++++------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/bukkit/src/main/java/net/william278/huskhomes/command/BukkitCommand.java b/bukkit/src/main/java/net/william278/huskhomes/command/BukkitCommand.java index 68086c3c..c6791510 100644 --- a/bukkit/src/main/java/net/william278/huskhomes/command/BukkitCommand.java +++ b/bukkit/src/main/java/net/william278/huskhomes/command/BukkitCommand.java @@ -7,7 +7,6 @@ import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -38,7 +37,6 @@ public class BukkitCommand implements CommandExecutor, TabExecutor { */ public void register(@NotNull PluginCommand pluginCommand) { try { - pluginCommand.setAliases(Arrays.asList(command.aliases)); pluginCommand.setPermission(command.permission); pluginCommand.setDescription(command.getDescription()); pluginCommand.setExecutor(this); diff --git a/bukkit/src/main/resources/plugin.yml b/bukkit/src/main/resources/plugin.yml index befb7600..c25c48c0 100644 --- a/bukkit/src/main/resources/plugin.yml +++ b/bukkit/src/main/resources/plugin.yml @@ -17,20 +17,24 @@ commands: usage: /sethome homelist: usage: /homelist [page] + aliases: [homes] delhome: usage: /delhome edithome: usage: /edithome [rename|description|relocate|privacy] [args] publichome: usage: /publichome [.] + aliases: [phome] publichomelist: usage: /publichomelist [page] + aliases: [phomelist, phomes] warp: usage: /warp setwarp: usage: /setwarp warplist: usage: /warplist [page] + aliases: [warps] delwarp: usage: /delwarp editwarp: diff --git a/common/src/main/java/net/william278/huskhomes/command/CommandBase.java b/common/src/main/java/net/william278/huskhomes/command/CommandBase.java index b4d4f377..a3a666d3 100644 --- a/common/src/main/java/net/william278/huskhomes/command/CommandBase.java +++ b/common/src/main/java/net/william278/huskhomes/command/CommandBase.java @@ -13,25 +13,29 @@ public abstract class CommandBase { /** * The input string to match for this command */ + @NotNull public final String command; /** * The permission node required to use this command */ - public final String permission; + @NotNull + protected final String permission; /** * Alias input strings for this command */ - public final String[] aliases; + @NotNull + protected final String[] aliases; /** * Instance of the implementing plugin */ - public final HuskHomes plugin; + @NotNull + protected final HuskHomes plugin; - - public CommandBase(@NotNull String command, @NotNull Permission permission, @NotNull HuskHomes implementor, String... aliases) { + protected CommandBase(@NotNull String command, @NotNull Permission permission, @NotNull HuskHomes implementor, + @NotNull String... aliases) { this.command = command; this.permission = permission.node; this.plugin = implementor; @@ -42,7 +46,7 @@ public abstract class CommandBase { * Fires when the command is executed * * @param onlineUser {@link OnlineUser} executing the command - * @param args Command arguments + * @param args Command arguments */ public abstract void onExecute(@NotNull OnlineUser onlineUser, @NotNull String[] args); @@ -51,6 +55,7 @@ public abstract class CommandBase { * * @return the command description */ + @NotNull public String getDescription() { return plugin.getLocales().getRawLocale(command + "_command_description") .orElse("A HuskHomes command");