Skip to content

Commit

Permalink
Help command shows only subcommands that player has access to
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksilassila committed Oct 21, 2020
1 parent 2b285dd commit 62659a3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public void onCommand(Player player, String[] args, boolean confirmed) {
player.sendMessage(Messages.help.AVAILABLE_COMMANDS);

for (Subcommand subcommand : commands.subcommands) {
player.sendMessage(Messages.help.SUBCOMMAND(subcommand));
if (subcommand.getPermission() == null || player.hasPermission(subcommand.getPermission()))
player.sendMessage(Messages.help.SUBCOMMAND(subcommand));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/me/aleksilassila/islands/utils/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public static class help {
public static final String GIVE = ChatColor.GRAY + "/island give <name> (You have to be on target island)";
public static final String DELETE = ChatColor.GRAY + "/island delete (You have to be on target island)";
public static final String HOME = error("Usage: /home <id>");
public static final String AVAILABLE_COMMANDS = ChatColor.WHITE + "Here's a list of available subcommands:";
public static final String AVAILABLE_COMMANDS = ChatColor.WHITE + "Here's a list of subcommands you have access to:";

public static String SUBCOMMAND(Subcommand subcommand) {
return ChatColor.WHITE + "" + ChatColor.BOLD + subcommand.getName() + ChatColor.RESET + ChatColor.GRAY + ": " + subcommand.help();
Expand Down

0 comments on commit 62659a3

Please sign in to comment.