Manually register aliases

This commit is contained in:
William committed 2022-08-17 23:19:39 +01:00
1 parent 435a9b9dff
commit 3b69b2df4d
3 files changed
+14 -7

No files matched your search

@@ -7,7 +7,6 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@@ -38,7 +37,6 @@ public class BukkitCommand implements CommandExecutor, TabExecutor {
*/ */
public void register(@NotNull PluginCommand pluginCommand) { public void register(@NotNull PluginCommand pluginCommand) {
try { try {
pluginCommand.setAliases(Arrays.asList(command.aliases));
pluginCommand.setPermission(command.permission); pluginCommand.setPermission(command.permission);
pluginCommand.setDescription(command.getDescription()); pluginCommand.setDescription(command.getDescription());
pluginCommand.setExecutor(this); pluginCommand.setExecutor(this);
+4
View File
@@ -17,20 +17,24 @@ commands:
usage: /sethome <name> usage: /sethome <name>
homelist: homelist:
usage: /homelist [page] usage: /homelist [page]
aliases: [homes]
delhome: delhome:
usage: /delhome <name> usage: /delhome <name>
edithome: edithome:
usage: /edithome <name> [rename|description|relocate|privacy] [args] usage: /edithome <name> [rename|description|relocate|privacy] [args]
publichome: publichome:
usage: /publichome [<owner_name>.<home_name>] usage: /publichome [<owner_name>.<home_name>]
aliases: [phome]
publichomelist: publichomelist:
usage: /publichomelist [page] usage: /publichomelist [page]
aliases: [phomelist, phomes]
warp: warp:
usage: /warp <name> usage: /warp <name>
setwarp: setwarp:
usage: /setwarp <name> usage: /setwarp <name>
warplist: warplist:
usage: /warplist [page] usage: /warplist [page]
aliases: [warps]
delwarp: delwarp:
usage: /delwarp <name> usage: /delwarp <name>
editwarp: editwarp:
@@ -13,25 +13,29 @@ public abstract class CommandBase {
/** /**
* The input string to match for this command * The input string to match for this command
*/ */
@NotNull
public final String command; public final String command;
/** /**
* The permission node required to use this command * The permission node required to use this command
*/ */
public final String permission; @NotNull
protected final String permission;
/** /**
* Alias input strings for this command * Alias input strings for this command
*/ */
public final String[] aliases; @NotNull
protected final String[] aliases;
/** /**
* Instance of the implementing plugin * Instance of the implementing plugin
*/ */
public final HuskHomes plugin; @NotNull
protected final HuskHomes plugin;
protected CommandBase(@NotNull String command, @NotNull Permission permission, @NotNull HuskHomes implementor,
public CommandBase(@NotNull String command, @NotNull Permission permission, @NotNull HuskHomes implementor, String... aliases) { @NotNull String... aliases) {
this.command = command; this.command = command;
this.permission = permission.node; this.permission = permission.node;
this.plugin = implementor; this.plugin = implementor;
@@ -51,6 +55,7 @@ public abstract class CommandBase {
* *
* @return the command description * @return the command description
*/ */
@NotNull
public String getDescription() { public String getDescription() {
return plugin.getLocales().getRawLocale(command + "_command_description") return plugin.getLocales().getRawLocale(command + "_command_description")
.orElse("A HuskHomes command"); .orElse("A HuskHomes command");