diff --git a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/commands/region/RegionCommands.java b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/commands/region/RegionCommands.java index 3e511025..c4a71246 100644 --- a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/commands/region/RegionCommands.java +++ b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/commands/region/RegionCommands.java @@ -71,6 +71,8 @@ import org.bukkit.entity.Player; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; @@ -498,7 +500,7 @@ public void flag(CommandContext args, CommandSender sender) throws CommandExcept // We didn't find the flag, so let's print a list of flags that the user // can use, and do nothing afterwards if (foundFlag == null) { - StringBuilder list = new StringBuilder(); + ArrayList flagList = new ArrayList<>(); // Need to build a list for (Flag flag : flagRegistry) { @@ -507,15 +509,30 @@ public void flag(CommandContext args, CommandSender sender) throws CommandExcept continue; } - if (list.length() > 0) { + flagList.add(flag.getName()); + } + + Collections.sort(flagList); + + StringBuilder list = new StringBuilder(); + + for (int i = 0; i < flagList.size(); i++) { + String flag = flagList.get(i); + + if (i % 2 == 0) { + list.append(ChatColor.GRAY); + } else { + list.append(ChatColor.RED); + } + + list.append(flag); + if ((i + 1) < flagList.size()) { list.append(", "); } - - list.append(flag.getName()); } sender.sendMessage(ChatColor.RED + "Unknown flag specified: " + flagName); - sender.sendMessage(ChatColor.RED + "Available " + "flags: " + list); + sender.sendMessage(ChatColor.RED + "Available flags: " + list); return; }