From e972cb4c1a021a144976c01a964b19aca6813ec9 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Mon, 4 Nov 2019 00:33:04 +0100 Subject: [PATCH 1/3] Make flag error messages translatable --- .../plotsquared/plot/config/Captions.java | 14 +++++++++++++- .../plotsquared/plot/flag/BooleanFlag.java | 2 +- .../plotsquared/plot/flag/DoubleFlag.java | 2 +- .../plotsquared/plot/flag/EnumFlag.java | 2 +- .../plotsquared/plot/flag/GameModeFlag.java | 2 +- .../plotsquared/plot/flag/IntegerFlag.java | 2 +- .../plotsquared/plot/flag/IntegerListFlag.java | 2 +- .../plotsquared/plot/flag/IntervalFlag.java | 2 +- .../plotsquared/plot/flag/LongFlag.java | 2 +- .../plotsquared/plot/flag/PlotBlockListFlag.java | 2 +- .../plotsquared/plot/flag/PlotWeatherFlag.java | 2 +- .../plotsquared/plot/flag/StringFlag.java | 2 +- .../plotsquared/plot/flag/StringListFlag.java | 2 +- 13 files changed, 25 insertions(+), 13 deletions(-) diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java index c319303b6..a27711e2b 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java @@ -548,7 +548,19 @@ public enum Captions { FLAG_CATEGORY_BOOLEAN("Boolean Flags", "Flags"), FLAG_CATEGORY_MIXED("Mixed Value Flags", "Flags"), // - + // + FLAG_ERROR_BOOLEAN("Flag value must be a boolean (true|false)", "Flags"), + FLAG_ERROR_ENUM("Must be one of: %s", "Flags"), + FLAG_ERROR_GAMEMODE("Flag value must be a gamemode: 'survival', 'creative', 'adventure' or 'spectator.", "Flags"), + FLAG_ERROR_INTEGER("Flag value must be a whole number", "Flags"), + FLAG_ERROR_INTEGER_LIST("Flag value must be an integer list", "Flags"), + FLAG_ERROR_INTERVAL("Value(s) must be numeric. /plot set flag [amount]", "Flags"), + FLAG_ERROR_LONG("Flag value must be a whole number (large numbers allowed)", "Flags"), + FLAG_ERROR_PLOTBLOCKLIST("Flag value must be a block list", "Flags"), + FLAG_ERROR_WEATHER("Flag must be a weather: 'rain' or 'sun'", "Flags"), + FLAG_ERROR_STRING("Flag value must be alphanumeric. Some special characters are allowed.", "Flags"), + FLAG_ERROR_STRINGLIST("Flag value must be a string list", "Flags"), + // // TRUSTED_ADDED("$4You successfully trusted a user to the plot", "Trusted"), WAS_NOT_ADDED("$2That player was not trusted on this plot", "Trusted"), diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/BooleanFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/BooleanFlag.java index 841df766c..692c0b501 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/BooleanFlag.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/BooleanFlag.java @@ -31,7 +31,7 @@ public class BooleanFlag extends Flag { } @Override public String getValueDescription() { - return "Flag value must be a boolean (true|false)"; + return Captions.FLAG_ERROR_BOOLEAN.getTranslated(); } public boolean isTrue(Plot plot) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/DoubleFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/DoubleFlag.java index 8cc665471..ab2c86c45 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/DoubleFlag.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/DoubleFlag.java @@ -22,6 +22,6 @@ public class DoubleFlag extends Flag { } @Override public String getValueDescription() { - return "Flag value must be a number."; + return Captions.FLAG_ERROR_BOOLEAN.getTranslated(); } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/EnumFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/EnumFlag.java index 88119bbaa..06936d4df 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/EnumFlag.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/EnumFlag.java @@ -28,6 +28,6 @@ public class EnumFlag extends Flag { } @Override public String getValueDescription() { - return "Must be one of: " + StringMan.getString(values); + return Captions.FLAG_ERROR_ENUM.getTranslated() + StringMan.getString(values); } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/GameModeFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/GameModeFlag.java index 26510b35b..023bf804a 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/GameModeFlag.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/GameModeFlag.java @@ -37,6 +37,6 @@ public class GameModeFlag extends Flag { } @Override public String getValueDescription() { - return "Flag value must be a gamemode: 'survival', 'creative', 'adventure' or 'spectator'"; + return Captions.FLAG_ERROR_GAMEMODE.getTranslated(); } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/IntegerFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/IntegerFlag.java index ced532cd1..8b527c46a 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/IntegerFlag.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/IntegerFlag.java @@ -10,7 +10,7 @@ public class IntegerFlag extends Flag { } @Override public String getValueDescription() { - return "Flag value must be a whole number"; + return Captions.FLAG_ERROR_INTEGER.getTranslated(); } @Override public String valueToString(Object value) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/IntegerListFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/IntegerListFlag.java index 1f24cb4a3..e9162000b 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/IntegerListFlag.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/IntegerListFlag.java @@ -27,6 +27,6 @@ public class IntegerListFlag extends ListFlag> { } @Override public String getValueDescription() { - return "Flag value must be an integer list"; + return Captions.FLAG_ERROR_INTEGER_LIST.getTranslated(); } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/IntervalFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/IntervalFlag.java index 0468c59b2..7b6b64d47 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/IntervalFlag.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/IntervalFlag.java @@ -40,7 +40,7 @@ public class IntervalFlag extends Flag { } @Override public String getValueDescription() { - return "Value(s) must be numeric. /plot set flag [amount]"; + return Captions.FLAG_ERROR_INTERVAL.getTranslated(); } @EqualsAndHashCode @RequiredArgsConstructor @Getter public static final class Interval { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/LongFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/LongFlag.java index 8d57e8865..1d8846701 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/LongFlag.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/LongFlag.java @@ -21,6 +21,6 @@ public class LongFlag extends Flag { } @Override public String getValueDescription() { - return "Flag value must be a whole number (large numbers allowed)"; + return Captions.FLAG_ERROR_LONG.getTranslated(); } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/PlotBlockListFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/PlotBlockListFlag.java index 93bd8c56f..1abaf32b0 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/PlotBlockListFlag.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/PlotBlockListFlag.java @@ -29,6 +29,6 @@ public class PlotBlockListFlag extends ListFlag> { } @Override public String getValueDescription() { - return "Flag value must be a block list"; + return Captions.FLAG_ERROR_PLOTBLOCKLIST.getTranslated(); } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/PlotWeatherFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/PlotWeatherFlag.java index 43544748f..1893d5370 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/PlotWeatherFlag.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/PlotWeatherFlag.java @@ -31,6 +31,6 @@ public class PlotWeatherFlag extends Flag { } @Override public String getValueDescription() { - return "Flag must be a weather: 'rain' or 'sun'"; + return Captions.FLAG_ERROR_WEATHER.getTranslated(); } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/StringFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/StringFlag.java index 6438ec938..779f47e0d 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/StringFlag.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/StringFlag.java @@ -18,6 +18,6 @@ public class StringFlag extends Flag { } @Override public String getValueDescription() { - return "Flag value must be alphanumeric. Some special characters are allowed."; + return Captions.FLAG_ERROR_STRING.getTranslated(); } } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/StringListFlag.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/StringListFlag.java index a1e28aa3d..eb76ec8c1 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/StringListFlag.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/StringListFlag.java @@ -22,6 +22,6 @@ public class StringListFlag extends ListFlag> { } @Override public String getValueDescription() { - return "Flag value must be a string list"; + return Captions.FLAG_ERROR_STRINGLIST.getTranslated(); } } From 315f26fb82c58b98f7dd0bf16bb06939c9ec663a Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Mon, 4 Nov 2019 00:46:08 +0100 Subject: [PATCH 2/3] Add missing color --- .../intellectualsites/plotsquared/bukkit/BukkitMain.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java index 272d09056..a7835f8db 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java @@ -698,11 +698,11 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain } } if (Settings.UUID.OFFLINE) { - PlotSquared.log(Captions.PREFIX + " &6" + getPluginName() + PlotSquared.log(Captions.PREFIX + "&6" + getPluginName() + " is using Offline Mode UUIDs either because of user preference, or because you are using an old version of " + "Bukkit"); } else { - PlotSquared.log(Captions.PREFIX + "" + getPluginName() + " is using online UUIDs"); + PlotSquared.log(Captions.PREFIX + "&6" + getPluginName() + " is using online UUIDs"); } if (Settings.UUID.USE_SQLUUIDHANDLER) { return new SQLUUIDHandler(wrapper); From a25511c8496fa92b3bde9b3df07b32a87d9e3285 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Mon, 4 Nov 2019 19:22:54 +0100 Subject: [PATCH 3/3] Add custom translations for special flags --- .../intellectualsites/plotsquared/plot/config/Captions.java | 4 +++- .../github/intellectualsites/plotsquared/plot/flag/Flags.java | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java index a27711e2b..68783e02e 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/config/Captions.java @@ -555,11 +555,13 @@ public enum Captions { FLAG_ERROR_INTEGER("Flag value must be a whole number", "Flags"), FLAG_ERROR_INTEGER_LIST("Flag value must be an integer list", "Flags"), FLAG_ERROR_INTERVAL("Value(s) must be numeric. /plot set flag [amount]", "Flags"), + FLAG_ERROR_KEEP("Flag value must be a timestamp or a boolean", "Flags"), FLAG_ERROR_LONG("Flag value must be a whole number (large numbers allowed)", "Flags"), FLAG_ERROR_PLOTBLOCKLIST("Flag value must be a block list", "Flags"), - FLAG_ERROR_WEATHER("Flag must be a weather: 'rain' or 'sun'", "Flags"), + FLAG_ERROR_PRICE("Flag value must be a positive number.", "Flags"), FLAG_ERROR_STRING("Flag value must be alphanumeric. Some special characters are allowed.", "Flags"), FLAG_ERROR_STRINGLIST("Flag value must be a string list", "Flags"), + FLAG_ERROR_WEATHER("Flag must be a weather: 'rain' or 'sun'", "Flags"), // // TRUSTED_ADDED("$4You successfully trusted a user to the plot", "Trusted"), diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/Flags.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/Flags.java index b21d6fb25..07e71a348 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/Flags.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/flag/Flags.java @@ -40,7 +40,7 @@ public final class Flags { } @Override public String getValueDescription() { - return "Flag value must be a positive number."; + return Captions.FLAG_ERROR_PRICE.getTranslated(); } }; public static final BooleanFlag EXPLOSION = new BooleanFlag("explosion"); @@ -114,7 +114,7 @@ public final class Flags { } @Override public String getValueDescription() { - return "Flag value must be a timestamp or a boolean"; + return Captions.FLAG_ERROR_KEEP.getTranslated(); } }; public static final TeleportDenyFlag DENY_TELEPORT = new TeleportDenyFlag("deny-teleport");