mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-26 02:57:42 +01:00
Make flag list more readble
This commit is contained in:
parent
4dc6e27660
commit
129bbd8ea1
@ -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<String> 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) {
|
||||
list.append(", ");
|
||||
flagList.add(flag.getName());
|
||||
}
|
||||
|
||||
list.append(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(", ");
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.RED + "Unknown flag specified: " + flagName);
|
||||
sender.sendMessage(ChatColor.RED + "Available " + "flags: " + list);
|
||||
sender.sendMessage(ChatColor.RED + "Available flags: " + list);
|
||||
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user