From f22065fd2ce6cc0e66fd7c350178730efbffefcb Mon Sep 17 00:00:00 2001 From: Tastybento Date: Tue, 26 Dec 2017 11:09:00 -0800 Subject: [PATCH] Fixed help and usage descriptions. Known issue - the help shown when doing a parent help is not using the child's custom help class for usage/description. --- locales/en_US.yml | 62 +++++++++++-------- .../api/commands/CompositeCommand.java | 17 ++--- .../api/commands/DefaultHelpCommand.java | 21 ++++--- .../bskyblock/commands/AdminCommand.java | 2 +- .../bskyblock/commands/IslandCommand.java | 4 +- .../commands/island/IslandAboutCommand.java | 2 +- .../commands/island/IslandCreateCommand.java | 2 +- .../commands/island/IslandGoCommand.java | 6 ++ .../commands/island/IslandMultiHomeHelp.java | 49 +++++++++++++++ .../commands/island/IslandResetCommand.java | 2 +- .../island/IslandResetnameCommand.java | 1 + .../commands/island/IslandSethomeCommand.java | 6 ++ .../commands/island/IslandSetnameCommand.java | 2 +- .../island/teams/IslandTeamCommand.java | 2 +- .../teams/IslandTeamInviteAcceptCommand.java | 1 + .../island/teams/IslandTeamInviteCommand.java | 1 + .../teams/IslandTeamInviteRejectCommand.java | 1 + .../island/teams/IslandTeamLeaveCommand.java | 1 + .../teams/IslandTeamPromoteCommand.java | 1 + .../teams/IslandTeamSetownerCommand.java | 1 + src/test/java/bskyblock/TestBSkyBlock.java | 8 +-- 21 files changed, 140 insertions(+), 52 deletions(-) create mode 100644 src/main/java/us/tastybento/bskyblock/commands/island/IslandMultiHomeHelp.java diff --git a/locales/en_US.yml b/locales/en_US.yml index 65e2f26fd..79493f161 100644 --- a/locales/en_US.yml +++ b/locales/en_US.yml @@ -34,82 +34,92 @@ commands: about: "display this help page" admin: version: - usage: "display %bsb_plugin_name% and addons versions" + description: "display %bsb_plugin_name% and addons versions" setrange: range-updated: "Island range updated to [number]" island: about: - usage: "display info about %bsb_plugin_name%" + description: "display info about %bsb_plugin_name%" go: - usage: "teleport you to your island" + usage: "" + description: "teleport you to your island" spawn: - usage: "teleport you to the spawn" + description: "teleport you to the spawn" create: - usage: "create an island" + description: "create an island" unable-create-island: "Your island could not be generated, please contact an administrator." info: - usage: "display info about your island" + description: "display info about your island" reset: - usage: "restart your island and remove the old one" + description: "restart your island and remove the old one" must-remove-members: "You must remove all members from your island before you can restart it (/island kick )." sethome: - usage: "set your teleport point for /island" + description: "set your teleport point for /island" must-be-on-your-island: "You must be on your island to set home!" num-homes: "Homes can be 1 to [max]." home-set: "Your island home has been set to your current location." + usage: "" setname: - usage: "set a name for your island" + description: "set a name for your island" name-too-short: "Too short. Minimum size is [length] characters." name-too-long: "Too long. Maximum size is [length] characters." + usage: "" resetname: - usage: "reset your island name" + description: "reset your island name" team: - usage: "manage your team" + description: "manage your team" info: - usage: "display detailed info about your team" + description: "display detailed info about your team" invite: - usage: "invite a player to join your island" + description: "invite a player to join your island" errors: island-is-full: "Your island is full, you can't invite anyone else." none-invited-you: "No one invited you :c." you-already-are-in-team: "You are already on a team!" invalid-invite: "That invite is no longer valid, sorry." + usage: "" you-can-invite: "You can invite [number] more players." accept: - usage: "accept an invitation" + description: "accept an invitation" you-joined-island: "You have joined an island! Use /[label] team info to see the other members." name-joined-your-island: "[name] has joined your island!" reject: - usage: "reject an invitation" + description: "reject an invitation" you-rejected-invite: "You have rejected the invitation to join an island." name-rejected-your-invite: "[name] has rejected your island invite!" cancel: - usage: "cancel the pending invite to join your island" + description: "cancel the pending invite to join your island" leave: - usage: "leave your island" + description: "leave your island" kick: - usage: "remove a member from your island" + description: "remove a member from your island" + usage: "" promote: - usage: "promote a player on your island to another rank" + description: "promote a player on your island to another rank" + usage: "" setowner: - usage: "transfer your island ownership to a member" + description: "transfer your island ownership to a member" errors: cant-transfer-to-yourself: "You can't transfer ownership to yourself! Well, in facts, you could have been able to do so... But we don't want you to do so. 'Cause it's bad." target-is-not-member: "That player is not part of your island team!" name-is-the-owner: "[name] is now the island owner!" + usage: "" you-are-the-owner: "You are now the island owner!" ban: - usage: "ban a player from your island" + description: "ban a player from your island" + usage: "" unban: - usage: "unban a player from your island" + description: "unban a player from your island" + usage: "" banlist: - usage: "list banned players" + description: "list banned players" lock: - usage: "lock/unlock your island so visitors cannot enter it" + description: "lock/unlock your island so visitors cannot enter it" settings: - usage: "display island settings" + description: "display island settings" language: - usage: "select language" + description: "select language" + usage: "" protection: flags: diff --git a/src/main/java/us/tastybento/bskyblock/api/commands/CompositeCommand.java b/src/main/java/us/tastybento/bskyblock/api/commands/CompositeCommand.java index 59995d603..358e322ec 100644 --- a/src/main/java/us/tastybento/bskyblock/api/commands/CompositeCommand.java +++ b/src/main/java/us/tastybento/bskyblock/api/commands/CompositeCommand.java @@ -71,9 +71,12 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi this.setAliases(new ArrayList<>(Arrays.asList(aliases))); this.subCommands = new LinkedHashMap<>(); setUsage(""); - if (!label.equals("help")) - new DefaultHelpCommand(this); + setDescription(""); this.setup(); + // If this command does not define its own help class, then use the default help command + if (!this.getSubCommand("help").isPresent() && !label.equals("help")) + new DefaultHelpCommand(this); + if (DEBUG) Bukkit.getLogger().info("DEBUG: registering command " + label); } @@ -155,7 +158,7 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi Bukkit.getLogger().info("DEBUG: This command has subcommands"); if (subCommand.hasSubCommand(args[i])) { // Step down one - subCommand = subCommand.getSubCommand(args[i]); + subCommand = subCommand.getSubCommand(args[i]).get(); if (DEBUG) Bukkit.getLogger().info("DEBUG: Moved to " + subCommand.getLabel()); } else { @@ -229,12 +232,12 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi * @param label - command label or alias * @return CompositeCommand or null if none found */ - public CompositeCommand getSubCommand(String label) { + public Optional getSubCommand(String label) { for (Map.Entry entry : subCommands.entrySet()) { - if (entry.getKey().equalsIgnoreCase(label)) return subCommands.get(label); - else if (entry.getValue().getAliases().contains(label)) return subCommands.get(entry.getValue().getLabel()); + if (entry.getKey().equalsIgnoreCase(label)) return Optional.of(subCommands.get(label)); + else if (entry.getValue().getAliases().contains(label)) return Optional.of(subCommands.get(entry.getValue().getLabel())); } - return null; + return Optional.empty(); } /** diff --git a/src/main/java/us/tastybento/bskyblock/api/commands/DefaultHelpCommand.java b/src/main/java/us/tastybento/bskyblock/api/commands/DefaultHelpCommand.java index b39666789..f6ea4faa7 100644 --- a/src/main/java/us/tastybento/bskyblock/api/commands/DefaultHelpCommand.java +++ b/src/main/java/us/tastybento/bskyblock/api/commands/DefaultHelpCommand.java @@ -1,5 +1,6 @@ package us.tastybento.bskyblock.api.commands; +import java.util.ArrayList; import java.util.List; /** @@ -19,29 +20,35 @@ public class DefaultHelpCommand extends CompositeCommand { @Override public boolean execute(User user, List args) { + if (args.isEmpty()) { // Show the top level help if (user.isPlayer()) { // Player. Check perms - if (user.hasPermission(parent.getPermission()) && user.hasPermission(parent.getPermission())) { - user.sendMessage(parent.getUsage()); + if (user.hasPermission(parent.getPermission())) { + user.sendMessage((parent.getUsage().isEmpty() ? "" : parent.getUsage() + " ") + parent.getDescription()); + } else { + user.sendMessage("errors.no-permission"); + return true; } - } else if (!parent.isOnlyPlayer() && !parent.isOnlyPlayer()) { + + } else if (!parent.isOnlyPlayer()) { // Console. Only show if it is a console command - user.sendMessage(parent.getUsage()); + user.sendMessage((parent.getUsage().isEmpty() ? "" : parent.getUsage() + " ") + parent.getDescription()); } // Run through any subcommands for (CompositeCommand subCommand : parent.getSubCommands().values()) { // Ignore the help command if (!subCommand.getLabel().equals("help")) { + String usage = subCommand.getUsage(); + String desc = subCommand.getDescription(); if (user.isPlayer()) { // Player. Check perms if (user.hasPermission(parent.getPermission()) && user.hasPermission(subCommand.getPermission())) { - user.sendMessage(subCommand.getUsage()); + user.sendMessage((usage.isEmpty() ? "" : usage + " ") + desc); } } else if (!subCommand.isOnlyPlayer()) { - // Console - user.sendMessage(subCommand.getUsage()); + user.sendMessage((usage.isEmpty() ? "" : usage + " ") + desc); } } } diff --git a/src/main/java/us/tastybento/bskyblock/commands/AdminCommand.java b/src/main/java/us/tastybento/bskyblock/commands/AdminCommand.java index 4d0279d0b..8510f7049 100755 --- a/src/main/java/us/tastybento/bskyblock/commands/AdminCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/AdminCommand.java @@ -22,7 +22,7 @@ public class AdminCommand extends CompositeCommand { @Override public boolean execute(User user, List args) { - return false; + return true; } } diff --git a/src/main/java/us/tastybento/bskyblock/commands/IslandCommand.java b/src/main/java/us/tastybento/bskyblock/commands/IslandCommand.java index 09a244197..0d983c444 100755 --- a/src/main/java/us/tastybento/bskyblock/commands/IslandCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/IslandCommand.java @@ -45,10 +45,10 @@ public class IslandCommand extends CompositeCommand { public boolean execute(User user, List args) { user.sendLegacyMessage("You successfully did /is !"); if (!getPlugin().getIslands().hasIsland(user.getUniqueId())) { - return this.getSubCommand("create").execute(user, args); + return this.getSubCommand("create").get().execute(user, args); } // Currently, just go home - return this.getSubCommand("go").execute(user, args); + return this.getSubCommand("go").get().execute(user, args); } } diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/IslandAboutCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/IslandAboutCommand.java index a48e234c5..560fe0f67 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/IslandAboutCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/IslandAboutCommand.java @@ -14,7 +14,7 @@ public class IslandAboutCommand extends CompositeCommand { */ public IslandAboutCommand(CompositeCommand islandCommand) { super(islandCommand, "about", "ab"); - this.setUsage("commands.island.about.usage"); + this.setDescription("commands.island.about.description"); } @Override diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/IslandCreateCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/IslandCreateCommand.java index f96e7e7c5..4250e5cc2 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/IslandCreateCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/IslandCreateCommand.java @@ -23,7 +23,7 @@ public class IslandCreateCommand extends CompositeCommand { super(islandCommand, "create", "auto"); this.setPermission(Settings.PERMPREFIX + "island.create"); this.setOnlyPlayer(true); - this.setUsage("commands.island.create.usage"); + this.setDescription("commands.island.create.description"); } /* (non-Javadoc) diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/IslandGoCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/IslandGoCommand.java index 9b5be2950..a2653079e 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/IslandGoCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/IslandGoCommand.java @@ -25,6 +25,12 @@ public class IslandGoCommand extends CompositeCommand { this.setPermission(Settings.PERMPREFIX + "island.home"); this.setOnlyPlayer(true); this.setUsage("commands.island.go.usage"); + this.setDescription("commands.island.go.description"); + } + + @Override + public void setup() { + new IslandMultiHomeHelp(this); } /* (non-Javadoc) diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/IslandMultiHomeHelp.java b/src/main/java/us/tastybento/bskyblock/commands/island/IslandMultiHomeHelp.java new file mode 100644 index 000000000..180ef627c --- /dev/null +++ b/src/main/java/us/tastybento/bskyblock/commands/island/IslandMultiHomeHelp.java @@ -0,0 +1,49 @@ +package us.tastybento.bskyblock.commands.island; + +import java.util.List; + +import us.tastybento.bskyblock.api.commands.CompositeCommand; +import us.tastybento.bskyblock.api.commands.User; +import us.tastybento.bskyblock.config.Settings; +import us.tastybento.bskyblock.util.Util; + +/** + * This is a customer help for the /island go and /island sethome commands. It overrides the default help sub command. + * The number of homes can change depending on the player's permissions and config.yml settings. + * @author ben + * + */ +public class IslandMultiHomeHelp extends CompositeCommand { + + private CompositeCommand parent; + + public IslandMultiHomeHelp(CompositeCommand parent) { + super(parent, "help"); + this.parent = parent; + this.setOnlyPlayer(true); + } + + @Override + public boolean execute(User user, List args) { + if (user.isPlayer()) { + user.sendLegacyMessage("DEBUG: Custom help"); + // Player. Check perms + if (user.hasPermission(parent.getPermission())) { + int maxHomes = Util.getPermValue(user.getPlayer(), Settings.PERMPREFIX + "island.maxhomes", Settings.maxHomes); + if (maxHomes > 1) { + user.sendMessage((parent.getUsage().isEmpty() ? "" : parent.getUsage() + " ") + parent.getDescription()); + } else { + user.sendMessage(parent.getDescription()); + } + return true; + } else { + user.sendMessage("errors.no-permission"); + return true; + } + + } + return false; + } + +} + diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/IslandResetCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/IslandResetCommand.java index a614a7b5c..42caf4a99 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/IslandResetCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/IslandResetCommand.java @@ -21,7 +21,7 @@ public class IslandResetCommand extends CompositeCommand { super(islandCommand, "reset", "restart"); this.setPermission(Settings.PERMPREFIX + "island.create"); this.setOnlyPlayer(true); - this.setUsage("commands.island.reset.usage"); + this.setDescription("commands.island.reset.description"); } @Override diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/IslandResetnameCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/IslandResetnameCommand.java index 03df32b33..40af59338 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/IslandResetnameCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/IslandResetnameCommand.java @@ -21,6 +21,7 @@ public class IslandResetnameCommand extends CompositeCommand { this.setPermission(Settings.PERMPREFIX + "island.name"); this.setOnlyPlayer(true); this.setUsage("commands.island.resetname.usage"); + this.setDescription("commands.island.resetname.description"); } diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/IslandSethomeCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/IslandSethomeCommand.java index 0559e01fb..9c3b6d964 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/IslandSethomeCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/IslandSethomeCommand.java @@ -15,6 +15,12 @@ public class IslandSethomeCommand extends CompositeCommand { this.setPermission(Settings.PERMPREFIX + "island.sethome"); this.setOnlyPlayer(true); this.setUsage("commands.island.sethome.usage"); + this.setDescription("commands.island.sethome.description"); + } + + @Override + public void setup() { + new IslandMultiHomeHelp(this); } @Override diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/IslandSetnameCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/IslandSetnameCommand.java index 40670cfbf..818446c7d 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/IslandSetnameCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/IslandSetnameCommand.java @@ -25,7 +25,7 @@ public class IslandSetnameCommand extends CompositeCommand { this.setPermission(Settings.PERMPREFIX + "island.name"); this.setOnlyPlayer(true); this.setUsage("commands.island.setname.usage"); - + this.setDescription("commands.island.setname.description"); } /* (non-Javadoc) diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamCommand.java index dbfd84782..df1a46f13 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamCommand.java @@ -22,7 +22,7 @@ public class IslandTeamCommand extends AbstractIslandTeamCommand { super(islandCommand, "team"); this.setPermission(Settings.PERMPREFIX + "island.team"); this.setOnlyPlayer(true); - this.setUsage("commands.island.team.usage"); + this.setDescription("commands.island.team.description"); } @Override diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamInviteAcceptCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamInviteAcceptCommand.java index 2d8fcffec..fc86e0cab 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamInviteAcceptCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamInviteAcceptCommand.java @@ -21,6 +21,7 @@ public class IslandTeamInviteAcceptCommand extends AbstractIslandTeamCommand { this.setPermission(Settings.PERMPREFIX + "island.team"); this.setOnlyPlayer(true); this.setUsage("commands.island.team.invite.accept.usage"); + this.setDescription("commands.island.team.invite.accept.description"); } @Override diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamInviteCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamInviteCommand.java index 6c5f453cf..fc54bee8a 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamInviteCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamInviteCommand.java @@ -25,6 +25,7 @@ public class IslandTeamInviteCommand extends AbstractIslandTeamCommand { this.setPermission(Settings.PERMPREFIX + "island.team"); this.setOnlyPlayer(true); this.setUsage("commands.island.team.invite.usage"); + this.setDescription("commands.island.team.invite.description"); } @Override diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamInviteRejectCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamInviteRejectCommand.java index 8d8fa7082..ff64fe471 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamInviteRejectCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamInviteRejectCommand.java @@ -16,6 +16,7 @@ public class IslandTeamInviteRejectCommand extends AbstractIslandTeamCommand { this.setPermission(Settings.PERMPREFIX + "island.team"); this.setOnlyPlayer(true); this.setUsage("commands.island.team.invite.reject.usage"); + this.setDescription("commands.island.team.invite.reject.description"); } @Override diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamLeaveCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamLeaveCommand.java index 5487493ac..926ae2902 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamLeaveCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamLeaveCommand.java @@ -12,6 +12,7 @@ public class IslandTeamLeaveCommand extends AbstractIslandTeamCommand { this.setPermission(Settings.PERMPREFIX + "island.team"); this.setOnlyPlayer(true); this.setUsage("command.island.team.leave.usage"); + this.setDescription("commands.island.team.leave.description"); } diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamPromoteCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamPromoteCommand.java index 55610871d..12327e44c 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamPromoteCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamPromoteCommand.java @@ -12,6 +12,7 @@ public class IslandTeamPromoteCommand extends AbstractIslandTeamCommand { this.setPermission(Settings.PERMPREFIX + "island.team"); this.setOnlyPlayer(true); this.setUsage("island.team.promote.usage"); + this.setDescription("commands.island.team.promote.description"); } @Override diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamSetownerCommand.java b/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamSetownerCommand.java index 106656315..c337301f1 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamSetownerCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/teams/IslandTeamSetownerCommand.java @@ -24,6 +24,7 @@ public class IslandTeamSetownerCommand extends AbstractIslandTeamCommand { this.setPermission(Settings.PERMPREFIX + "island.team"); this.setOnlyPlayer(true); this.setUsage("commands.island.team.setowner.usage"); + this.setDescription("commands.island.team.setowner.description"); } @Override diff --git a/src/test/java/bskyblock/TestBSkyBlock.java b/src/test/java/bskyblock/TestBSkyBlock.java index 46b979d48..45dbebdd7 100644 --- a/src/test/java/bskyblock/TestBSkyBlock.java +++ b/src/test/java/bskyblock/TestBSkyBlock.java @@ -91,10 +91,10 @@ public class TestBSkyBlock { assertEquals(Settings.PERMPREFIX + "default.permission", testCommand.getPermission()); // Check commands and aliases match to correct class for (Entry command : testCommand.getSubCommands().entrySet()) { - assertEquals(testCommand.getSubCommand(command.getKey()), command.getValue()); + assertEquals(testCommand.getSubCommand(command.getKey()), Optional.of(command.getValue())); // Check aliases for (String alias : command.getValue().getAliases()) { - assertEquals(testCommand.getSubCommand(alias), command.getValue()); + assertEquals(testCommand.getSubCommand(alias), Optional.of(command.getValue())); } } String[] args = {""}; @@ -107,11 +107,11 @@ public class TestBSkyBlock { args[0] = "sub1"; assertEquals(Arrays.asList(), testCommand.tabComplete(player, "test", args)); String[] args2 = {"sub2",""}; - assertEquals(Arrays.asList("help", "subsub"), testCommand.tabComplete(player, "test", args2)); + assertEquals(Arrays.asList("subsub", "help"), testCommand.tabComplete(player, "test", args2)); args2[1] = "s"; assertEquals(Arrays.asList("subsub"), testCommand.tabComplete(player, "test", args2)); String[] args3 = {"sub2","subsub", ""}; - assertEquals(Arrays.asList("help", "subsubsub"), testCommand.tabComplete(player, "test", args3)); + assertEquals(Arrays.asList("subsubsub", "help"), testCommand.tabComplete(player, "test", args3)); // Test for overridden tabcomplete assertEquals(Arrays.asList(new String[] {"Florian", "Ben", "Bill", "Ted", "help"}), testCommand.tabComplete(player, "test", new String[] {"sub2", "subsub", "subsubsub", ""}));