Make the flag list output message configurable.

This commit is contained in:
Alexander Söderberg 2019-10-27 11:55:15 +01:00
parent 01eee306f1
commit cb52ee8cfb
2 changed files with 29 additions and 24 deletions

View File

@ -300,15 +300,19 @@ public class FlagCmd extends SubCommand {
flags.computeIfAbsent(category, k -> new ArrayList<>());
flagList.add(flag1.getName());
}
StringBuilder message = new StringBuilder();
String prefix = "";
for (Map.Entry<String, ArrayList<String>> entry : flags.entrySet()) {
String category = entry.getKey();
List<String> flagNames = entry.getValue();
final StringBuilder message = new StringBuilder();
final Iterator<Map.Entry<String, ArrayList<String>>> iterator =
flags.entrySet().iterator();
while (iterator.hasNext()) {
final Map.Entry<String, ArrayList<String>> flagsEntry = iterator.next();
final List<String> flagNames = flagsEntry.getValue();
Collections.sort(flagNames);
message.append(prefix).append("&6").append(category).append(": &7")
.append(StringMan.join(flagNames, ", "));
prefix = "\n";
message.append(String.format(Captions.FLAG_LIST_ENTRY.formatted(),
flagsEntry.getKey(), StringMan.join(flagNames, ", ")));
if (iterator.hasNext()) {
message.append("\n");
}
}
MainUtil.sendMessage(player, message.toString());
return true;

View File

@ -532,7 +532,24 @@ public enum Captions {
FLAG_REMOVED("$4Successfully removed flag", "Flag"),
FLAG_ADDED("$4Successfully added flag", "Flag"),
FLAG_TUTORIAL_USAGE("$1Have an admin set the flag: $2%s", "CommandConfig"),
FLAG_LIST_ENTRY("$2%s: $1%s", "Flag"),
//</editor-fold>
//<editor-fold desc="Flag category captions">
FLAG_CATEGORY_STRING("String Flags", "Flags"),
FLAG_CATEGORY_INTEGERS("Integer Flags", "Flags"),
FLAG_CATEGORY_TELEPORT_DENY("Teleport Deny Flag", "Flags"),
FLAG_CATEGORY_STRING_LIST("String List Flags", "Flags"),
FLAG_CATEGORY_WEATHER("Weather Flags", "Flags"),
FLAG_CATEGORY_BLOCK_LIST("Material Flags", "Flags"),
FLAG_CATEGORY_INTERVALS("Interval Flags", "Flags"),
FLAG_CATEGORY_INTEGER_LIST("Integer List Flags", "Flags"),
FLAG_CATEGORY_GAMEMODE("Game Mode Flags", "Flags"),
FLAG_CATEGORY_ENUM("Generic Enum Flags", "Flags"),
FLAG_CATEGORY_DECIMAL("Decimal Flags", "Flags"),
FLAG_CATEGORY_BOOLEAN("Boolean Flags", "Flags"),
FLAG_CATEGORY_MIXED("Mixed Value Flags", "Flags"),
//</editor-fold>
//<editor-fold desc="Trusted">
TRUSTED_ADDED("$4You successfully trusted a user to the plot", "Trusted"),
WAS_NOT_ADDED("$2That player was not trusted on this plot", "Trusted"),
@ -585,22 +602,6 @@ public enum Captions {
GRANTED_PLOT_FAILED("$1Grant failed: $2%s", "Grants"),
//</editor-fold>
//<editor-fold desc="Flag category captions">
FLAG_CATEGORY_STRING("String Flags", "Flags"),
FLAG_CATEGORY_INTEGERS("Integer Flags", "Flags"),
FLAG_CATEGORY_TELEPORT_DENY("Teleport Deny Flag", "Flags"),
FLAG_CATEGORY_STRING_LIST("String List Flags", "Flags"),
FLAG_CATEGORY_WEATHER("Weather Flags", "Flags"),
FLAG_CATEGORY_BLOCK_LIST("Material Flags", "Flags"),
FLAG_CATEGORY_INTERVALS("Interval Flags", "Flags"),
FLAG_CATEGORY_INTEGER_LIST("Integer List Flags", "Flags"),
FLAG_CATEGORY_GAMEMODE("Game Mode Flags", "Flags"),
FLAG_CATEGORY_ENUM("Generic Enum Flags", "Flags"),
FLAG_CATEGORY_DECIMAL("Decimal Flags", "Flags"),
FLAG_CATEGORY_BOOLEAN("Boolean Flags", "Flags"),
FLAG_CATEGORY_MIXED("Mixed Value Flags", "Flags"),
//</editor-fold>
/**
* Legacy Configuration Conversion
*/