diff --git a/gradle.properties b/gradle.properties index 585329f587..12adb88a7d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ author = masa mod_file_name = malilib-fabric # Current mod version -mod_version = 0.19.999-sakura.6-translations.3 +mod_version = 0.19.999-sakura.6-translations.4 # Minecraft, Fabric Loader and API and mappings versions minecraft_version_out = 1.21 diff --git a/src/main/java/fi/dy/masa/malilib/config/IConfigBase.java b/src/main/java/fi/dy/masa/malilib/config/IConfigBase.java index caf3f1971e..eb477769e9 100644 --- a/src/main/java/fi/dy/masa/malilib/config/IConfigBase.java +++ b/src/main/java/fi/dy/masa/malilib/config/IConfigBase.java @@ -55,11 +55,7 @@ default String getTranslatedName() return this.getName(); } - /** - * Set translatedName - * @param translatedName (Name to set) - */ - default void setTranslatedName(String translatedName) { } + void setTranslatedName(String translatedName); /** * Set the value of this config option from a JSON element (is possible) diff --git a/src/main/java/fi/dy/masa/malilib/config/options/ConfigBase.java b/src/main/java/fi/dy/masa/malilib/config/options/ConfigBase.java index a1381b4dac..770cd30a9c 100644 --- a/src/main/java/fi/dy/masa/malilib/config/options/ConfigBase.java +++ b/src/main/java/fi/dy/masa/malilib/config/options/ConfigBase.java @@ -24,12 +24,17 @@ public ConfigBase(ConfigType type, String name, String comment) } public ConfigBase(ConfigType type, String name, String comment, String prettyName) + { + this(type, name, comment, prettyName, name); + } + + public ConfigBase(ConfigType type, String name, String comment, String prettyName, String translatedName) { this.type = type; this.name = name; - this.prettyName = prettyName; this.comment = comment; - this.translatedName = name; + this.prettyName = prettyName; + this.translatedName = translatedName; } @Override diff --git a/src/main/java/fi/dy/masa/malilib/config/options/ConfigBoolean.java b/src/main/java/fi/dy/masa/malilib/config/options/ConfigBoolean.java index 4c329d822e..4d490cc112 100644 --- a/src/main/java/fi/dy/masa/malilib/config/options/ConfigBoolean.java +++ b/src/main/java/fi/dy/masa/malilib/config/options/ConfigBoolean.java @@ -18,7 +18,12 @@ public ConfigBoolean(String name, boolean defaultValue, String comment) public ConfigBoolean(String name, boolean defaultValue, String comment, String prettyName) { - super(ConfigType.BOOLEAN, name, comment, prettyName); + this(name, defaultValue, comment, prettyName, name); + } + + public ConfigBoolean(String name, boolean defaultValue, String comment, String prettyName, String translatedName) + { + super(ConfigType.BOOLEAN, name, comment, prettyName, translatedName); this.defaultValue = defaultValue; this.value = defaultValue; diff --git a/src/main/java/fi/dy/masa/malilib/config/options/ConfigBooleanHotkeyed.java b/src/main/java/fi/dy/masa/malilib/config/options/ConfigBooleanHotkeyed.java index 3d55fc8234..7538634868 100644 --- a/src/main/java/fi/dy/masa/malilib/config/options/ConfigBooleanHotkeyed.java +++ b/src/main/java/fi/dy/masa/malilib/config/options/ConfigBooleanHotkeyed.java @@ -22,12 +22,12 @@ public ConfigBooleanHotkeyed(String name, boolean defaultValue, String defaultHo public ConfigBooleanHotkeyed(String name, boolean defaultValue, String defaultHotkey, String comment, String prettyName) { - this(name, defaultValue, defaultHotkey, KeybindSettings.DEFAULT, comment, prettyName); + this(name, defaultValue, defaultHotkey, KeybindSettings.DEFAULT, comment, prettyName, name); } - public ConfigBooleanHotkeyed(String name, boolean defaultValue, String defaultHotkey, KeybindSettings settings, String comment, String prettyName) + public ConfigBooleanHotkeyed(String name, boolean defaultValue, String defaultHotkey, KeybindSettings settings, String comment, String prettyName, String translatedName) { - super(name, defaultValue, comment, prettyName); + super(name, defaultValue, comment, prettyName, translatedName); this.keybind = KeybindMulti.fromStorageString(defaultHotkey, settings); this.keybind.setCallback(new KeyCallbackToggleBooleanConfigWithMessage(this)); diff --git a/src/main/java/fi/dy/masa/malilib/config/options/ConfigColor.java b/src/main/java/fi/dy/masa/malilib/config/options/ConfigColor.java index 51600fc824..74af28bba1 100644 --- a/src/main/java/fi/dy/masa/malilib/config/options/ConfigColor.java +++ b/src/main/java/fi/dy/masa/malilib/config/options/ConfigColor.java @@ -11,16 +11,21 @@ public class ConfigColor extends ConfigInteger { private Color4f color; - public ConfigColor(String name, String defaultValue, String comment, String prettyName) + public ConfigColor(String name, String defaultValue, String comment) { - super(name, StringUtils.getColor(defaultValue, 0), comment, prettyName); + this(name, defaultValue, comment, name); + } - this.color = Color4f.fromColor(this.getIntegerValue()); + public ConfigColor(String name, String defaultValue, String comment, String prettyName) + { + this(name, defaultValue, comment, prettyName, name); } - public ConfigColor(String name, String defaultValue, String comment) + public ConfigColor(String name, String defaultValue, String comment, String prettyName, String translatedName) { - this(name, defaultValue, comment, name); + super(name, StringUtils.getColor(defaultValue, 0), comment, prettyName, translatedName); + + this.color = Color4f.fromColor(this.getIntegerValue()); } @Override @@ -73,7 +78,7 @@ public boolean isModified(String newValue) { return StringUtils.getColor(newValue, 0) != this.getDefaultIntegerValue(); } - catch (Exception e) + catch (Exception ignored) { } diff --git a/src/main/java/fi/dy/masa/malilib/config/options/ConfigColorList.java b/src/main/java/fi/dy/masa/malilib/config/options/ConfigColorList.java index c2c0bc1f5c..5151ae1e81 100644 --- a/src/main/java/fi/dy/masa/malilib/config/options/ConfigColorList.java +++ b/src/main/java/fi/dy/masa/malilib/config/options/ConfigColorList.java @@ -20,15 +20,17 @@ public class ConfigColorList extends ConfigBase implements ICon public ConfigColorList(String name, ImmutableList defaultValue, String comment) { - super(ConfigType.COLOR_LIST, name, comment); - - this.defaultValue = defaultValue; - this.colors.addAll(defaultValue); + this(name, defaultValue, comment, name); } public ConfigColorList(String name, ImmutableList defaultValue, String comment, String prettyName) { - super(ConfigType.COLOR_LIST, name, comment, prettyName); + this(name, defaultValue, comment, prettyName, name); + } + + public ConfigColorList(String name, ImmutableList defaultValue, String comment, String prettyName, String translatedName) + { + super(ConfigType.COLOR_LIST, name, comment, prettyName, translatedName); this.defaultValue = defaultValue; this.colors.addAll(defaultValue); diff --git a/src/main/java/fi/dy/masa/malilib/config/options/ConfigDouble.java b/src/main/java/fi/dy/masa/malilib/config/options/ConfigDouble.java index c0f962d91e..49fc240c87 100644 --- a/src/main/java/fi/dy/masa/malilib/config/options/ConfigDouble.java +++ b/src/main/java/fi/dy/masa/malilib/config/options/ConfigDouble.java @@ -22,22 +22,32 @@ public ConfigDouble(String name, double defaultValue, String comment) public ConfigDouble(String name, double defaultValue, String comment, String prettyName) { - this(name, defaultValue, Double.MIN_VALUE, Double.MAX_VALUE, comment, prettyName); + this(name, defaultValue, Double.MIN_VALUE, Double.MAX_VALUE, comment, prettyName, name); + } + + public ConfigDouble(String name, double defaultValue, String comment, String prettyName, String translatedName) + { + this(name, defaultValue, Double.MIN_VALUE, Double.MAX_VALUE, comment, prettyName, translatedName); } public ConfigDouble(String name, double defaultValue, double minValue, double maxValue, String comment) { - this(name, defaultValue, minValue, maxValue, false, comment, name); + this(name, defaultValue, minValue, maxValue, comment, name); } public ConfigDouble(String name, double defaultValue, double minValue, double maxValue, String comment, String prettyName) { - this(name, defaultValue, minValue, maxValue, false, comment, prettyName); + this(name, defaultValue, minValue, maxValue, false, comment, prettyName, name); } - public ConfigDouble(String name, double defaultValue, double minValue, double maxValue, boolean useSlider, String comment, String prettyName) + public ConfigDouble(String name, double defaultValue, double minValue, double maxValue, String comment, String prettyName, String translatedName) { - super(ConfigType.DOUBLE, name, comment, prettyName); + this(name, defaultValue, minValue, maxValue, false, comment, prettyName, translatedName); + } + + public ConfigDouble(String name, double defaultValue, double minValue, double maxValue, boolean useSlider, String comment, String prettyName, String translatedName) + { + super(ConfigType.DOUBLE, name, comment, prettyName, translatedName); this.minValue = minValue; this.maxValue = maxValue; @@ -112,7 +122,7 @@ public boolean isModified(String newValue) { return Double.parseDouble(newValue) != this.defaultValue; } - catch (Exception e) + catch (Exception ignored) { } diff --git a/src/main/java/fi/dy/masa/malilib/config/options/ConfigHotkey.java b/src/main/java/fi/dy/masa/malilib/config/options/ConfigHotkey.java index e3c20d597d..8edfac3429 100644 --- a/src/main/java/fi/dy/masa/malilib/config/options/ConfigHotkey.java +++ b/src/main/java/fi/dy/masa/malilib/config/options/ConfigHotkey.java @@ -18,19 +18,29 @@ public ConfigHotkey(String name, String defaultStorageString, String comment) this(name, defaultStorageString, comment, name); } - public ConfigHotkey(String name, String defaultStorageString, KeybindSettings settings, String comment) + public ConfigHotkey(String name, String defaultStorageString, String comment, String prettyName) { - this(name, defaultStorageString, settings, comment, StringUtils.splitCamelCase(name)); + this(name, defaultStorageString, KeybindSettings.DEFAULT, comment, prettyName, name); } - public ConfigHotkey(String name, String defaultStorageString, String comment, String prettyName) + public ConfigHotkey(String name, String defaultStorageString, String comment, String prettyName, String translatedName) + { + this(name, defaultStorageString, KeybindSettings.DEFAULT, comment, prettyName, translatedName); + } + + public ConfigHotkey(String name, String defaultStorageString, KeybindSettings settings, String comment) { - this(name, defaultStorageString, KeybindSettings.DEFAULT, comment, prettyName); + this(name, defaultStorageString, settings, comment, StringUtils.splitCamelCase(name), name); } public ConfigHotkey(String name, String defaultStorageString, KeybindSettings settings, String comment, String prettyName) { - super(ConfigType.HOTKEY, name, comment, prettyName); + this(name, defaultStorageString, settings, comment, prettyName, name); + } + + public ConfigHotkey(String name, String defaultStorageString, KeybindSettings settings, String comment, String prettyName, String translatedName) + { + super(ConfigType.HOTKEY, name, comment, prettyName, translatedName); this.keybind = KeybindMulti.fromStorageString(defaultStorageString, settings); } diff --git a/src/main/java/fi/dy/masa/malilib/config/options/ConfigInteger.java b/src/main/java/fi/dy/masa/malilib/config/options/ConfigInteger.java index 22b2dd2f5c..7c76ca1656 100644 --- a/src/main/java/fi/dy/masa/malilib/config/options/ConfigInteger.java +++ b/src/main/java/fi/dy/masa/malilib/config/options/ConfigInteger.java @@ -22,27 +22,37 @@ public ConfigInteger(String name, int defaultValue, String comment) public ConfigInteger(String name, int defaultValue, String comment, String prettyName) { - this(name, defaultValue, Integer.MIN_VALUE, Integer.MAX_VALUE, comment, prettyName); + this(name, defaultValue, Integer.MIN_VALUE, Integer.MAX_VALUE, comment, prettyName, name); + } + + public ConfigInteger(String name, int defaultValue, String comment, String prettyName, String translatedName) + { + this(name, defaultValue, Integer.MIN_VALUE, Integer.MAX_VALUE, comment, prettyName, translatedName); } public ConfigInteger(String name, int defaultValue, int minValue, int maxValue, String comment) { - this(name, defaultValue, minValue, maxValue, false, comment, name); + this(name, defaultValue, minValue, maxValue, false, comment, name, name); } public ConfigInteger(String name, int defaultValue, int minValue, int maxValue, String comment, String prettyName) { - this(name, defaultValue, minValue, maxValue, false, comment, prettyName); + this(name, defaultValue, minValue, maxValue, false, comment, prettyName, name); + } + + public ConfigInteger(String name, int defaultValue, int minValue, int maxValue, String comment, String prettyName, String translatedName) + { + this(name, defaultValue, minValue, maxValue, false, comment, prettyName, translatedName); } public ConfigInteger(String name, int defaultValue, int minValue, int maxValue, boolean useSlider, String comment) { - this(name, defaultValue, minValue, maxValue, useSlider, comment, name); + this(name, defaultValue, minValue, maxValue, useSlider, comment, name, name); } - public ConfigInteger(String name, int defaultValue, int minValue, int maxValue, boolean useSlider, String comment, String prettyName) + public ConfigInteger(String name, int defaultValue, int minValue, int maxValue, boolean useSlider, String comment, String prettyName, String translatedName) { - super(ConfigType.INTEGER, name, comment, prettyName); + super(ConfigType.INTEGER, name, comment, prettyName, translatedName); this.minValue = minValue; this.maxValue = maxValue; @@ -117,7 +127,7 @@ public boolean isModified(String newValue) { return Integer.parseInt(newValue) != this.defaultValue; } - catch (Exception e) + catch (Exception ignored) { } diff --git a/src/main/java/fi/dy/masa/malilib/config/options/ConfigOptionList.java b/src/main/java/fi/dy/masa/malilib/config/options/ConfigOptionList.java index ff51aced1d..de1c5ecf2e 100644 --- a/src/main/java/fi/dy/masa/malilib/config/options/ConfigOptionList.java +++ b/src/main/java/fi/dy/masa/malilib/config/options/ConfigOptionList.java @@ -20,7 +20,12 @@ public ConfigOptionList(String name, IConfigOptionListEntry defaultValue, String public ConfigOptionList(String name, IConfigOptionListEntry defaultValue, String comment, String prettyName) { - super(ConfigType.OPTION_LIST, name, comment, prettyName); + this(name, defaultValue, comment, prettyName, name); + } + + public ConfigOptionList(String name, IConfigOptionListEntry defaultValue, String comment, String prettyName, String translatedName) + { + super(ConfigType.OPTION_LIST, name, comment, prettyName, translatedName); this.defaultValue = defaultValue; this.value = defaultValue; @@ -63,7 +68,7 @@ public boolean isModified(String newValue) { return this.value.fromString(newValue) != this.defaultValue; } - catch (Exception e) + catch (Exception ignored) { } diff --git a/src/main/java/fi/dy/masa/malilib/config/options/ConfigString.java b/src/main/java/fi/dy/masa/malilib/config/options/ConfigString.java index 4fd4e9c8a5..c460b1ce3d 100644 --- a/src/main/java/fi/dy/masa/malilib/config/options/ConfigString.java +++ b/src/main/java/fi/dy/masa/malilib/config/options/ConfigString.java @@ -19,7 +19,12 @@ public ConfigString(String name, String defaultValue, String comment) public ConfigString(String name, String defaultValue, String comment, String prettyName) { - super(ConfigType.STRING, name, comment, prettyName); + this(name, defaultValue, comment, prettyName, name); + } + + public ConfigString(String name, String defaultValue, String comment, String prettyName, String translatedName) + { + super(ConfigType.STRING, name, comment, prettyName, translatedName); this.defaultValue = defaultValue; this.value = defaultValue; diff --git a/src/main/java/fi/dy/masa/malilib/config/options/ConfigStringList.java b/src/main/java/fi/dy/masa/malilib/config/options/ConfigStringList.java index 726dca5fb6..9e2e5d842a 100644 --- a/src/main/java/fi/dy/masa/malilib/config/options/ConfigStringList.java +++ b/src/main/java/fi/dy/masa/malilib/config/options/ConfigStringList.java @@ -22,7 +22,12 @@ public ConfigStringList(String name, ImmutableList defaultValue, String public ConfigStringList(String name, ImmutableList defaultValue, String comment, String prettyName) { - super(ConfigType.STRING_LIST, name, comment, prettyName); + this(name, defaultValue, comment, prettyName, name); + } + + public ConfigStringList(String name, ImmutableList defaultValue, String comment, String prettyName, String translatedName) + { + super(ConfigType.STRING_LIST, name, comment, prettyName, translatedName); this.defaultValue = defaultValue; this.strings.addAll(defaultValue); diff --git a/src/main/java/fi/dy/masa/malilib/config/options/ConfigTypeWrapper.java b/src/main/java/fi/dy/masa/malilib/config/options/ConfigTypeWrapper.java index 1d05f37021..5b60079f7a 100644 --- a/src/main/java/fi/dy/masa/malilib/config/options/ConfigTypeWrapper.java +++ b/src/main/java/fi/dy/masa/malilib/config/options/ConfigTypeWrapper.java @@ -48,11 +48,11 @@ public void toggleUseSlider() { if (this.wrappedConfig instanceof IConfigInteger) { - ((IConfigInteger) this.wrappedConfig).toggleUseSlider();; + ((IConfigInteger) this.wrappedConfig).toggleUseSlider(); } else if (this.wrappedConfig instanceof IConfigDouble) { - ((IConfigDouble) this.wrappedConfig).toggleUseSlider();; + ((IConfigDouble) this.wrappedConfig).toggleUseSlider(); } } @@ -86,6 +86,18 @@ public String getConfigGuiDisplayName() return this.wrappedConfig.getConfigGuiDisplayName(); } + @Override + public String getTranslatedName() + { + return this.wrappedConfig.getTranslatedName(); + } + + @Override + public void setTranslatedName(String translatedName) + { + this.wrappedConfig.setTranslatedName(translatedName); + } + @SuppressWarnings("unchecked") @Override public void onValueChanged() @@ -109,33 +121,31 @@ public void setValueChangeCallback(IValueChangeCallback callback) @Override public String getStringValue() { - switch (this.wrappedType) + return switch (this.wrappedType) { - case BOOLEAN: return String.valueOf(((IConfigBoolean) this.wrappedConfig).getBooleanValue()); - case DOUBLE: return String.valueOf(((IConfigDouble) this.wrappedConfig).getDoubleValue()); - case INTEGER: return String.valueOf(((IConfigInteger) this.wrappedConfig).getIntegerValue()); - case COLOR: return String.format("#%08X", ((IConfigInteger) this.wrappedConfig).getIntegerValue()); - case OPTION_LIST: return ((IConfigOptionList) this.wrappedConfig).getOptionListValue().getStringValue(); - case HOTKEY: return ((IHotkey) this.wrappedConfig).getKeybind().getStringValue(); - case STRING: - default: return ((IStringRepresentable) this.wrappedConfig).getStringValue(); - } + case BOOLEAN -> String.valueOf(((IConfigBoolean) this.wrappedConfig).getBooleanValue()); + case DOUBLE -> String.valueOf(((IConfigDouble) this.wrappedConfig).getDoubleValue()); + case INTEGER -> String.valueOf(((IConfigInteger) this.wrappedConfig).getIntegerValue()); + case COLOR -> String.format("#%08X", ((IConfigInteger) this.wrappedConfig).getIntegerValue()); + case OPTION_LIST -> ((IConfigOptionList) this.wrappedConfig).getOptionListValue().getStringValue(); + case HOTKEY -> ((IHotkey) this.wrappedConfig).getKeybind().getStringValue(); + default -> ((IStringRepresentable) this.wrappedConfig).getStringValue(); + }; } @Override public String getDefaultStringValue() { - switch (this.wrappedType) + return switch (this.wrappedType) { - case BOOLEAN: return String.valueOf(((IConfigBoolean) this.wrappedConfig).getDefaultBooleanValue()); - case DOUBLE: return String.valueOf(((IConfigDouble) this.wrappedConfig).getDefaultDoubleValue()); - case INTEGER: return String.valueOf(((IConfigInteger) this.wrappedConfig).getDefaultIntegerValue()); - case COLOR: return String.format("#%08X", ((IConfigInteger) this.wrappedConfig).getDefaultIntegerValue()); - case OPTION_LIST: return ((IConfigOptionList) this.wrappedConfig).getDefaultOptionListValue().getStringValue(); - case HOTKEY: return ((IHotkey) this.wrappedConfig).getKeybind().getDefaultStringValue(); - case STRING: - default: return ((IStringRepresentable) this.wrappedConfig).getDefaultStringValue(); - } + case BOOLEAN -> String.valueOf(((IConfigBoolean) this.wrappedConfig).getDefaultBooleanValue()); + case DOUBLE -> String.valueOf(((IConfigDouble) this.wrappedConfig).getDefaultDoubleValue()); + case INTEGER -> String.valueOf(((IConfigInteger) this.wrappedConfig).getDefaultIntegerValue()); + case COLOR -> String.format("#%08X", ((IConfigInteger) this.wrappedConfig).getDefaultIntegerValue()); + case OPTION_LIST -> ((IConfigOptionList) this.wrappedConfig).getDefaultOptionListValue().getStringValue(); + case HOTKEY -> ((IHotkey) this.wrappedConfig).getKeybind().getDefaultStringValue(); + default -> ((IStringRepresentable) this.wrappedConfig).getDefaultStringValue(); + }; } @Override @@ -179,62 +189,55 @@ public void setValueFromString(String value) @Override public boolean isModified() { - switch (this.wrappedType) + return switch (this.wrappedType) { - case HOTKEY: - return ((IHotkey) this.wrappedConfig).getKeybind().isModified(); - case BOOLEAN: + case HOTKEY -> ((IHotkey) this.wrappedConfig).getKeybind().isModified(); + case BOOLEAN -> { IConfigBoolean config = (IConfigBoolean) this.wrappedConfig; - return config.getBooleanValue() != config.getDefaultBooleanValue(); + yield config.getBooleanValue() != config.getDefaultBooleanValue(); } - case DOUBLE: + case DOUBLE -> { IConfigDouble config = (IConfigDouble) this.wrappedConfig; - return config.getDoubleValue() != config.getDefaultDoubleValue(); + yield config.getDoubleValue() != config.getDefaultDoubleValue(); } - case INTEGER: - case COLOR: + case INTEGER, COLOR -> { IConfigInteger config = (IConfigInteger) this.wrappedConfig; - return config.getIntegerValue() != config.getDefaultIntegerValue(); + yield config.getIntegerValue() != config.getDefaultIntegerValue(); } - case OPTION_LIST: + case OPTION_LIST -> { IConfigOptionList config = (IConfigOptionList) this.wrappedConfig; - return config.getOptionListValue() != config.getDefaultOptionListValue(); + yield config.getOptionListValue() != config.getDefaultOptionListValue(); } - case STRING: + case STRING -> { IStringRepresentable config = (IStringRepresentable) this.wrappedConfig; - return config.getStringValue().equals(config.getDefaultStringValue()) == false; + yield config.getStringValue().equals(config.getDefaultStringValue()) == false; } - default: - return false; - } + default -> false; + }; } @Override public boolean isModified(String newValue) { - switch (this.wrappedType) + return switch (this.wrappedType) { - case HOTKEY: - return ((IHotkey) this.wrappedConfig).getKeybind().isModified(newValue); - case BOOLEAN: - return String.valueOf(((IConfigBoolean) this.wrappedConfig).getBooleanValue()).equals(newValue) == false; - case DOUBLE: - return String.valueOf(((IConfigDouble) this.wrappedConfig).getDoubleValue()).equals(newValue) == false; - case INTEGER: - return String.valueOf(((IConfigInteger) this.wrappedConfig).getIntegerValue()).equals(newValue) == false; - case COLOR: - return ((ConfigColor) this.wrappedConfig).getStringValue().equals(newValue) == false; - case OPTION_LIST: - return ((IConfigOptionList) this.wrappedConfig).getOptionListValue().getStringValue().equals(newValue) == false; - case STRING: - default: - return ((IStringRepresentable) this.wrappedConfig).getStringValue().equals(newValue) == false; - } + case HOTKEY -> ((IHotkey) this.wrappedConfig).getKeybind().isModified(newValue); + case BOOLEAN -> + String.valueOf(((IConfigBoolean) this.wrappedConfig).getBooleanValue()).equals(newValue) == false; + case DOUBLE -> + String.valueOf(((IConfigDouble) this.wrappedConfig).getDoubleValue()).equals(newValue) == false; + case INTEGER -> + String.valueOf(((IConfigInteger) this.wrappedConfig).getIntegerValue()).equals(newValue) == false; + case COLOR -> ((ConfigColor) this.wrappedConfig).getStringValue().equals(newValue) == false; + case OPTION_LIST -> + ((IConfigOptionList) this.wrappedConfig).getOptionListValue().getStringValue().equals(newValue) == false; + default -> ((IStringRepresentable) this.wrappedConfig).getStringValue().equals(newValue) == false; + }; } @Override @@ -442,24 +445,17 @@ public void setValueFromJsonElement(JsonElement element) @Override public JsonElement getAsJsonElement() { - switch (this.wrappedType) + return switch (this.wrappedType) { - case BOOLEAN: - return new JsonPrimitive(((IConfigBoolean) this.wrappedConfig).getBooleanValue()); - case DOUBLE: - return new JsonPrimitive(((IConfigDouble) this.wrappedConfig).getDoubleValue()); - case INTEGER: - return new JsonPrimitive(((IConfigInteger) this.wrappedConfig).getIntegerValue()); - case STRING: - return new JsonPrimitive(((IConfigValue) this.wrappedConfig).getStringValue()); - case COLOR: - return new JsonPrimitive(((IConfigInteger) this.wrappedConfig).getStringValue()); - case OPTION_LIST: - return new JsonPrimitive(((IConfigOptionList) this.wrappedConfig).getOptionListValue().getStringValue()); - case HOTKEY: - return ((IHotkey) this.wrappedConfig).getAsJsonElement(); - default: - return new JsonPrimitive(this.getStringValue()); - } + case BOOLEAN -> new JsonPrimitive(((IConfigBoolean) this.wrappedConfig).getBooleanValue()); + case DOUBLE -> new JsonPrimitive(((IConfigDouble) this.wrappedConfig).getDoubleValue()); + case INTEGER -> new JsonPrimitive(((IConfigInteger) this.wrappedConfig).getIntegerValue()); + case STRING -> new JsonPrimitive(((IConfigValue) this.wrappedConfig).getStringValue()); + case COLOR -> new JsonPrimitive(((IConfigInteger) this.wrappedConfig).getStringValue()); + case OPTION_LIST -> + new JsonPrimitive(((IConfigOptionList) this.wrappedConfig).getOptionListValue().getStringValue()); + case HOTKEY -> ((IHotkey) this.wrappedConfig).getAsJsonElement(); + default -> new JsonPrimitive(this.getStringValue()); + }; } }