Make flag error messages translatable

This commit is contained in:
NotMyFault 2019-11-04 00:33:04 +01:00
parent 7309e61221
commit e972cb4c1a
13 changed files with 25 additions and 13 deletions

View File

@ -548,7 +548,19 @@ public enum Captions {
FLAG_CATEGORY_BOOLEAN("Boolean Flags", "Flags"), FLAG_CATEGORY_BOOLEAN("Boolean Flags", "Flags"),
FLAG_CATEGORY_MIXED("Mixed Value Flags", "Flags"), FLAG_CATEGORY_MIXED("Mixed Value Flags", "Flags"),
//</editor-fold> //</editor-fold>
//<editor-fold desc="Flag category errors">
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 <flag> <interval> [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"),
//</editor-fold>
//<editor-fold desc="Trusted"> //<editor-fold desc="Trusted">
TRUSTED_ADDED("$4You successfully trusted a user to the plot", "Trusted"), TRUSTED_ADDED("$4You successfully trusted a user to the plot", "Trusted"),
WAS_NOT_ADDED("$2That player was not trusted on this plot", "Trusted"), WAS_NOT_ADDED("$2That player was not trusted on this plot", "Trusted"),

View File

@ -31,7 +31,7 @@ public class BooleanFlag extends Flag<Boolean> {
} }
@Override public String getValueDescription() { @Override public String getValueDescription() {
return "Flag value must be a boolean (true|false)"; return Captions.FLAG_ERROR_BOOLEAN.getTranslated();
} }
public boolean isTrue(Plot plot) { public boolean isTrue(Plot plot) {

View File

@ -22,6 +22,6 @@ public class DoubleFlag extends Flag<Double> {
} }
@Override public String getValueDescription() { @Override public String getValueDescription() {
return "Flag value must be a number."; return Captions.FLAG_ERROR_BOOLEAN.getTranslated();
} }
} }

View File

@ -28,6 +28,6 @@ public class EnumFlag extends Flag<String> {
} }
@Override public String getValueDescription() { @Override public String getValueDescription() {
return "Must be one of: " + StringMan.getString(values); return Captions.FLAG_ERROR_ENUM.getTranslated() + StringMan.getString(values);
} }
} }

View File

@ -37,6 +37,6 @@ public class GameModeFlag extends Flag<PlotGameMode> {
} }
@Override public String getValueDescription() { @Override public String getValueDescription() {
return "Flag value must be a gamemode: 'survival', 'creative', 'adventure' or 'spectator'"; return Captions.FLAG_ERROR_GAMEMODE.getTranslated();
} }
} }

View File

@ -10,7 +10,7 @@ public class IntegerFlag extends Flag<Integer> {
} }
@Override public String getValueDescription() { @Override public String getValueDescription() {
return "Flag value must be a whole number"; return Captions.FLAG_ERROR_INTEGER.getTranslated();
} }
@Override public String valueToString(Object value) { @Override public String valueToString(Object value) {

View File

@ -27,6 +27,6 @@ public class IntegerListFlag extends ListFlag<List<Integer>> {
} }
@Override public String getValueDescription() { @Override public String getValueDescription() {
return "Flag value must be an integer list"; return Captions.FLAG_ERROR_INTEGER_LIST.getTranslated();
} }
} }

View File

@ -40,7 +40,7 @@ public class IntervalFlag extends Flag<IntervalFlag.Interval> {
} }
@Override public String getValueDescription() { @Override public String getValueDescription() {
return "Value(s) must be numeric. /plot set flag <flag> <interval> [amount]"; return Captions.FLAG_ERROR_INTERVAL.getTranslated();
} }
@EqualsAndHashCode @RequiredArgsConstructor @Getter public static final class Interval { @EqualsAndHashCode @RequiredArgsConstructor @Getter public static final class Interval {

View File

@ -21,6 +21,6 @@ public class LongFlag extends Flag<Long> {
} }
@Override public String getValueDescription() { @Override public String getValueDescription() {
return "Flag value must be a whole number (large numbers allowed)"; return Captions.FLAG_ERROR_LONG.getTranslated();
} }
} }

View File

@ -29,6 +29,6 @@ public class PlotBlockListFlag extends ListFlag<HashSet<PlotBlock>> {
} }
@Override public String getValueDescription() { @Override public String getValueDescription() {
return "Flag value must be a block list"; return Captions.FLAG_ERROR_PLOTBLOCKLIST.getTranslated();
} }
} }

View File

@ -31,6 +31,6 @@ public class PlotWeatherFlag extends Flag<PlotWeather> {
} }
@Override public String getValueDescription() { @Override public String getValueDescription() {
return "Flag must be a weather: 'rain' or 'sun'"; return Captions.FLAG_ERROR_WEATHER.getTranslated();
} }
} }

View File

@ -18,6 +18,6 @@ public class StringFlag extends Flag<String> {
} }
@Override public String getValueDescription() { @Override public String getValueDescription() {
return "Flag value must be alphanumeric. Some special characters are allowed."; return Captions.FLAG_ERROR_STRING.getTranslated();
} }
} }

View File

@ -22,6 +22,6 @@ public class StringListFlag extends ListFlag<List<String>> {
} }
@Override public String getValueDescription() { @Override public String getValueDescription() {
return "Flag value must be a string list"; return Captions.FLAG_ERROR_STRINGLIST.getTranslated();
} }
} }