diff --git a/src/main/java/exopandora/worldhandler/config/Config.java b/src/main/java/exopandora/worldhandler/config/Config.java index 396c084..9410e1d 100644 --- a/src/main/java/exopandora/worldhandler/config/Config.java +++ b/src/main/java/exopandora/worldhandler/config/Config.java @@ -48,14 +48,6 @@ public class Config this.sliders = new ConfigCategorySliders(builder); } - public void read() - { - this.getSettings().read(); - this.getButcher().read(); - this.getSkin().read(); - this.getSliders().read(); - } - public ConfigCategorySettings getSettings() { return this.settings; @@ -112,7 +104,6 @@ public class Config { Config.MOD_CONFIG = event.getConfig(); Config.CONFIG_DATA = (CommentedFileConfig) Config.MOD_CONFIG.getConfigData(); - Config.CLIENT.read(); } } @@ -122,8 +113,6 @@ public class Config if(event.getConfig().getType().equals(Type.CLIENT) && Config.CONFIG_DATA != null) { Config.CONFIG_DATA.load(); - Config.CLIENT.read(); - KeyHandler.updatePosKeys(); } } diff --git a/src/main/java/exopandora/worldhandler/config/ConfigCategoryButcher.java b/src/main/java/exopandora/worldhandler/config/ConfigCategoryButcher.java index b967aaa..ef08671 100644 --- a/src/main/java/exopandora/worldhandler/config/ConfigCategoryButcher.java +++ b/src/main/java/exopandora/worldhandler/config/ConfigCategoryButcher.java @@ -1,8 +1,10 @@ package exopandora.worldhandler.config; -import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.stream.Collectors; + +import com.google.common.base.Predicates; import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; @@ -14,68 +16,47 @@ import net.minecraftforge.registries.ForgeRegistries; @OnlyIn(Dist.CLIENT) public class ConfigCategoryButcher { - private final List entities = new ArrayList(); - - private final ConfigValue> valueEntities; + private final ConfigValue> entities; public ConfigCategoryButcher(ForgeConfigSpec.Builder builder) { builder.push("butcher"); - this.valueEntities = builder.defineList("entities", Collections.emptyList(), this::isValid); + this.entities = builder.defineList("entities", Collections.emptyList(), this::isValid); builder.pop(); } - public void read() - { - this.entities.clear(); - this.entities.addAll(this.valueEntities.get()); - } - - private void write() - { - Config.set(this.valueEntities, this.entities); - } - public List getEntities() { - List list = new ArrayList(); - - for(String entity : this.entities) - { - ResourceLocation resource = ResourceLocation.tryCreate(entity); - - if(resource != null) - { - list.add(resource); - } - } - - return list; + return this.entities.get().stream().map(ResourceLocation::tryCreate).filter(Predicates.notNull()).collect(Collectors.toList()); } public boolean containsEntity(ResourceLocation entity) { - return this.entities.contains(entity.toString()); + return this.getEntities().contains(entity); } public void addEntity(ResourceLocation entity) { if(this.isValid(entity)) { - this.entities.add(entity.toString()); - this.write(); + @SuppressWarnings("unchecked") + List entities = (List) this.entities.get(); + entities.add(entity.toString()); + Config.set(this.entities, entities); } } public boolean removeEntity(ResourceLocation entity) { - boolean removed = this.entities.remove(entity.toString()); + @SuppressWarnings("unchecked") + List entities = (List) this.entities.get(); + boolean removed = entities.remove(entity.toString()); if(removed) { - this.write(); + Config.set(this.entities, entities); } return removed; diff --git a/src/main/java/exopandora/worldhandler/config/ConfigCategorySettings.java b/src/main/java/exopandora/worldhandler/config/ConfigCategorySettings.java index 397fb60..b84e5c7 100644 --- a/src/main/java/exopandora/worldhandler/config/ConfigCategorySettings.java +++ b/src/main/java/exopandora/worldhandler/config/ConfigCategorySettings.java @@ -12,101 +12,85 @@ import net.minecraftforge.common.ForgeConfigSpec.IntValue; @OnlyIn(Dist.CLIENT) public class ConfigCategorySettings { - private boolean commandSyntax; - private boolean shortcuts; - private boolean shortcutKeys; - private boolean tooltips; - private boolean watch; - private boolean smoothWatch; - private boolean pause; - private boolean customTimes; - private boolean permissionQuery; - private boolean highlightBlocks; - private int dawn; - private int noon; - private int sunset; - private int midnight; - private String blockPlacingMode; - - private final BooleanValue valueCommandSyntax; - private final BooleanValue valueShortcuts; - private final BooleanValue valueShortcutKeys; - private final BooleanValue valueTooltips; - private final BooleanValue valueWatch; - private final BooleanValue valueSmoothWatch; - private final BooleanValue valuePause; - private final BooleanValue valueCustomTimes; - private final BooleanValue valuePermissionQuery; - private final BooleanValue valueHighlightBlocks; - private final IntValue valueDawn; - private final IntValue valueNoon; - private final IntValue valueSunset; - private final IntValue valueMidnight; - private final ConfigValue valueBlockPlacingMode; + private final BooleanValue commandSyntax; + private final BooleanValue shortcuts; + private final BooleanValue shortcutKeys; + private final BooleanValue tooltips; + private final BooleanValue watch; + private final BooleanValue smoothWatch; + private final BooleanValue pause; + private final BooleanValue customTimes; + private final BooleanValue permissionQuery; + private final BooleanValue highlightBlocks; + private final IntValue dawn; + private final IntValue noon; + private final IntValue sunset; + private final IntValue midnight; + private final ConfigValue blockPlacingMode; public ConfigCategorySettings(ForgeConfigSpec.Builder builder) { builder.push("settings"); - this.valueCommandSyntax = builder + this.commandSyntax = builder .translation("gui.worldhandler.config.settings.command_syntax") .comment("Whether or not to display the current command at the bottom") .define("command_syntax", false); - this.valueShortcuts = builder + this.shortcuts = builder .translation("gui.worldhandler.config.settings.shortcuts") .comment("Whether or not to display a row of quick access buttons at the top") .define("shortcuts", false); - this.valueShortcutKeys = builder + this.shortcutKeys = builder .translation("gui.worldhandler.config.settings.key_shortcuts") .comment("Whether or not to enable button keys for pos1 and pos2") .define("key_shortcuts", false); - this.valueTooltips = builder + this.tooltips = builder .translation("gui.worldhandler.config.settings.tooltips") .comment("Whether or not to display tooltips for buttons") .define("tooltips", true); - this.valueWatch = builder + this.watch = builder .translation("gui.worldhandler.config.settings.watch") .comment("Whether or not to display a watch") .define("watch", true); - this.valueSmoothWatch = builder + this.smoothWatch = builder .translation("gui.worldhandler.config.settings.smooth_watch") .comment("Whether or not the watch pointers move smoothly") .define("smooth_watch", true); - this.valuePause = builder + this.pause = builder .translation("gui.worldhandler.config.settings.pause_game") .comment("Whether or not to pause the game when the gui is opened") .define("pause_game", false); - this.valueCustomTimes = builder + this.customTimes = builder .translation("gui.worldhandler.config.settings.custom_times") .comment("Whether or not to use the custom times") .define("custom_times", false); - this.valuePermissionQuery = builder + this.permissionQuery = builder .translation("gui.worldhandler.config.settings.permission_query") .comment("Whether or not the permission query is enabled") .define("permission_query", true); - this.valueHighlightBlocks = builder + this.highlightBlocks = builder .translation("gui.worldhandler.config.settings.highlight_blocks") .comment("Whether or not selected blocks will be highlighted") .define("highlight_blocks", true); - this.valueDawn = builder + this.dawn = builder .translation("gui.worldhandler.config.settings.custom_time_dawn") .comment("Ticks upon dawn") .defineInRange("custom_time_dawn", 1000, 0, 24000); - this.valueNoon = builder + this.noon = builder .translation("gui.worldhandler.config.settings.custom_time_noon") .comment("Ticks upon noon") .defineInRange("custom_time_noon", 6000, 0, 24000); - this.valueSunset = builder + this.sunset = builder .translation("gui.worldhandler.config.settings.custom_time_sunset") .comment("Ticks upon sunset") .defineInRange("custom_time_sunset", 12500, 0, 24000); - this.valueMidnight = builder + this.midnight = builder .translation("gui.worldhandler.config.settings.custom_time_midnight") .comment("Ticks upon midnight") .defineInRange("custom_time_midnight", 18000, 0, 24000); - this.valueBlockPlacingMode = builder + this.blockPlacingMode = builder .translation("gui.worldhandler.config.settings.block_placing_mode") .comment("Block placing mode (keep, replace, destroy)") .defineInList("block_placing_mode", "keep", Arrays.asList("keep", "replace", "destroy")); @@ -114,206 +98,153 @@ public class ConfigCategorySettings builder.pop(); } - public void read() - { - this.commandSyntax = this.valueCommandSyntax.get(); - this.shortcuts = this.valueShortcuts.get(); - this.shortcutKeys = this.valueShortcutKeys.get(); - this.tooltips = this.valueTooltips.get(); - this.watch = this.valueWatch.get(); - this.smoothWatch = this.valueSmoothWatch.get(); - this.pause = this.valuePause.get(); - this.customTimes = this.valueCustomTimes.get(); - this.permissionQuery = this.valuePermissionQuery.get(); - this.highlightBlocks = this.valueHighlightBlocks.get(); - this.dawn = this.valueDawn.get(); - this.noon = this.valueNoon.get(); - this.sunset = this.valueSunset.get(); - this.midnight = this.valueMidnight.get(); - this.blockPlacingMode = this.valueBlockPlacingMode.get(); - } - - private void write() - { - Config.set(this.valueCommandSyntax, this.commandSyntax); - Config.set(this.valueShortcuts, this.shortcuts); - Config.set(this.valueShortcutKeys, this.shortcutKeys); - Config.set(this.valueTooltips, this.tooltips); - Config.set(this.valueWatch, this.watch); - Config.set(this.valueSmoothWatch, this.smoothWatch); - Config.set(this.valuePause, this.pause); - Config.set(this.valueCustomTimes, this.customTimes); - Config.set(this.valuePermissionQuery, this.permissionQuery); - Config.set(this.valueHighlightBlocks, this.highlightBlocks); - Config.set(this.valueDawn, this.dawn); - Config.set(this.valueNoon, this.noon); - Config.set(this.valueSunset, this.sunset); - Config.set(this.valueMidnight, this.midnight); - Config.set(this.valueBlockPlacingMode, this.blockPlacingMode); - } - public boolean commandSyntax() { - return this.commandSyntax; + return this.commandSyntax.get(); } public void setCommandSyntax(boolean enabled) { - this.commandSyntax = enabled; - this.write(); + Config.set(this.commandSyntax, enabled); } public boolean shortcuts() { - return this.shortcuts; + return this.shortcuts.get(); } public void setShortcuts(boolean enabled) { - this.shortcuts = enabled; - this.write(); + Config.set(this.shortcuts, enabled); } public boolean shortcutKeys() { - return this.shortcutKeys; + return this.shortcutKeys.get(); } public void setShortcutKeys(boolean enabled) { - this.shortcutKeys = enabled; - this.write(); + Config.set(this.shortcutKeys, enabled); } public boolean tooltips() { - return this.tooltips; + return this.tooltips.get(); } public void setTooltips(boolean enabled) { - this.tooltips = enabled; - this.write(); + Config.set(this.tooltips, enabled); } public boolean watch() { - return this.watch; + return this.watch.get(); } public void setWatch(boolean enabled) { - this.watch = enabled; - this.write(); + Config.set(this.watch, enabled); } public boolean smoothWatch() { - return this.smoothWatch; + return this.smoothWatch.get(); } public void setSmoothWatch(boolean enabled) { - this.smoothWatch = enabled; - this.write(); + Config.set(this.smoothWatch, enabled); } public boolean pause() { - return this.pause; + return this.pause.get(); } public void setPause(boolean enabled) { - this.pause = enabled; - this.write(); + Config.set(this.pause, enabled); } public boolean customTimes() { - return this.customTimes; + return this.customTimes.get(); } public void setCustomTimes(boolean enabled) { - this.customTimes = enabled; - this.write(); + Config.set(this.customTimes, enabled); } public boolean permissionQuery() { - return this.permissionQuery; + return this.permissionQuery.get(); } public void setPermissionQuery(boolean enabled) { - this.permissionQuery = enabled; - this.write(); + Config.set(this.permissionQuery, enabled); } public boolean highlightBlocks() { - return this.highlightBlocks; + return this.highlightBlocks.get(); } public void setHighlightBlocks(boolean enabled) { - this.highlightBlocks = enabled; - this.write(); + Config.set(this.highlightBlocks, enabled); } public int getDawn() { - return this.dawn; + return this.dawn.get(); } public void setDawn(int ticks) { - this.dawn = ticks; - this.write(); + Config.set(this.dawn, ticks); } public int getNoon() { - return this.noon; + return this.noon.get(); } public void setNoon(int ticks) { - this.noon = ticks; - this.write(); + Config.set(this.noon, ticks); } public int getSunset() { - return this.sunset; + return this.sunset.get(); } public void setSunset(int ticks) { - this.sunset = ticks; - this.write(); + Config.set(this.sunset, ticks); } public int getMidnight() { - return this.midnight; + return this.midnight.get(); } public void setMidnight(int ticks) { - this.midnight = ticks; - this.write(); + Config.set(this.midnight, ticks); } public String getBlockPlacingMode() { - return this.blockPlacingMode; + return this.blockPlacingMode.get(); } public void setBlockPlacingMode(String mode) { - this.blockPlacingMode = mode; - this.write(); + Config.set(this.blockPlacingMode, mode); } } \ No newline at end of file diff --git a/src/main/java/exopandora/worldhandler/config/ConfigCategorySkin.java b/src/main/java/exopandora/worldhandler/config/ConfigCategorySkin.java index decf35d..f1f037b 100644 --- a/src/main/java/exopandora/worldhandler/config/ConfigCategorySkin.java +++ b/src/main/java/exopandora/worldhandler/config/ConfigCategorySkin.java @@ -12,97 +12,82 @@ import net.minecraftforge.common.ForgeConfigSpec.IntValue; @OnlyIn(Dist.CLIENT) public class ConfigCategorySkin { - private EnumIconSize iconSize; - private int labelColor; - private int headlineColor; - private int backgroundRed; - private int backgroundGreen; - private int backgroundBlue; - private int backgroundAlpha; - private int buttonRed; - private int buttonGreen; - private int buttonBlue; - private int buttonAlpha; - private String type; - private boolean sharpEdges; - private boolean drawBackground; - - private final ConfigValue valueIconSize; - private final IntValue valueLabelColor; - private final IntValue valueHeadlineColor; - private final IntValue valueBackgroundRed; - private final IntValue valueBackgroundGreen; - private final IntValue valueBackgroundBlue; - private final IntValue valueBackgroundAlpha; - private final IntValue valueButtonRed; - private final IntValue valueButtonGreen; - private final IntValue valueButtonBlue; - private final IntValue valueButtonAlpha; - private final ConfigValue valueType; - private final BooleanValue valueSharpEdges; - private final BooleanValue valueDrawBackground; + private final ConfigValue iconSize; + private final IntValue labelColor; + private final IntValue headlineColor; + private final IntValue backgroundRed; + private final IntValue backgroundGreen; + private final IntValue backgroundBlue; + private final IntValue backgroundAlpha; + private final IntValue buttonRed; + private final IntValue buttonGreen; + private final IntValue buttonBlue; + private final IntValue buttonAlpha; + private final ConfigValue type; + private final BooleanValue sharpEdges; + private final BooleanValue drawBackground; public ConfigCategorySkin(ForgeConfigSpec.Builder builder) { builder.push("skin"); - this.valueIconSize = builder + this.iconSize = builder .translation("gui.worldhandler.config.skin.icon_size") .comment("Size of the icons") .defineEnum("icon_size", EnumIconSize.x16, EnumIconSize.values()); - this.valueLabelColor = builder + this.labelColor = builder .translation("gui.worldhandler.config.skin.label_color") .comment("Label color") .defineInRange("label_color", 0x1F1F1F, 0x80000000, 0x7FFFFFFF); - this.valueHeadlineColor = builder + this.headlineColor = builder .translation("gui.worldhandler.config.skin.headline_color") .comment("Headline color") .defineInRange("headline_color", 0x4F4F4F, 0x80000000, 0x7FFFFFFF); - this.valueBackgroundRed = builder + this.backgroundRed = builder .translation("gui.worldhandler.config.skin.background_red") .comment("Background red") .defineInRange("background_red", 255, 0, 255); - this.valueBackgroundGreen = builder + this.backgroundGreen = builder .translation("gui.worldhandler.config.skin.background_green") .comment("Background green") .defineInRange("background_green", 255, 0, 255); - this.valueBackgroundBlue = builder + this.backgroundBlue = builder .translation("gui.worldhandler.config.skin.background_blue") .comment("Background blue") .defineInRange("background_blue", 255, 0, 255); - this.valueBackgroundAlpha = builder + this.backgroundAlpha = builder .translation("gui.worldhandler.config.skin.background_alpha") .comment("Background alpha") .defineInRange("background_alpha", 255, 0, 255); - this.valueButtonRed = builder + this.buttonRed = builder .translation("gui.worldhandler.config.skin.button_red") - .comment("Button eed") + .comment("Button red") .defineInRange("button_red", 255, 0, 255); - this.valueButtonGreen = builder + this.buttonGreen = builder .translation("gui.worldhandler.config.skin.button_green") .comment("Button green") .defineInRange("button_green", 255, 0, 255); - this.valueButtonBlue = builder + this.buttonBlue = builder .translation("gui.worldhandler.config.skin.button_blue") .comment("Button blue") .defineInRange("button_blue", 255, 0, 255); - this.valueButtonAlpha = builder + this.buttonAlpha = builder .translation("gui.worldhandler.config.skin.button_alpha") .comment("Button alpha") .defineInRange("button_alpha", 255, 0, 255); - this.valueType = builder + this.type = builder .translation("gui.worldhandler.config.skin.textures") .comment("Background texture (resourcepack, vanilla)") .defineInList("textures", "resourcepack", Arrays.asList("resourcepack", "vanilla")); - this.valueSharpEdges = builder + this.sharpEdges = builder .translation("gui.worldhandler.config.settings.sharp_tab_edges") .comment("Whether or not the gui has sharp or smooth tab edges") .define("sharp_tab_edges", false); - this.valueDrawBackground = builder + this.drawBackground = builder .translation("gui.worldhandler.config.settings.draw_background") .comment("Whether or not to enable background drawing") .define("draw_background", true); @@ -110,78 +95,39 @@ public class ConfigCategorySkin builder.pop(); } - public void read() - { - this.iconSize = this.valueIconSize.get(); - this.labelColor = this.valueLabelColor.get(); - this.headlineColor = this.valueHeadlineColor.get(); - this.backgroundRed = this.valueBackgroundRed.get(); - this.backgroundGreen = this.valueBackgroundGreen.get(); - this.backgroundBlue = this.valueBackgroundBlue.get(); - this.backgroundAlpha = this.valueBackgroundAlpha.get(); - this.buttonRed = this.valueButtonRed.get(); - this.buttonGreen = this.valueButtonGreen.get(); - this.buttonBlue = this.valueButtonBlue.get(); - this.buttonAlpha = this.valueButtonAlpha.get(); - this.type = this.valueType.get(); - this.sharpEdges = this.valueSharpEdges.get(); - this.drawBackground = this.valueDrawBackground.get(); - } - - private void write() - { - Config.set(this.valueIconSize, this.iconSize); - Config.set(this.valueLabelColor, this.labelColor); - Config.set(this.valueHeadlineColor, this.headlineColor); - Config.set(this.valueBackgroundRed, this.backgroundRed); - Config.set(this.valueBackgroundGreen, this.backgroundGreen); - Config.set(this.valueBackgroundBlue, this.backgroundBlue); - Config.set(this.valueBackgroundAlpha, this.backgroundAlpha); - Config.set(this.valueButtonRed, this.buttonRed); - Config.set(this.valueButtonGreen, this.buttonGreen); - Config.set(this.valueButtonBlue, this.buttonBlue); - Config.set(this.valueButtonAlpha, this.buttonAlpha); - Config.set(this.valueType, this.type); - Config.set(this.valueSharpEdges, this.sharpEdges); - Config.set(this.valueDrawBackground, this.drawBackground); - } - public EnumIconSize getIconSize() { - return this.iconSize; + return this.iconSize.get(); } public void setIconSize(EnumIconSize size) { - this.iconSize = size; - this.write(); + Config.set(this.iconSize, size); } public int getLabelColor() { - return this.labelColor; + return this.labelColor.get(); } public void setLabelColor(int color) { - this.labelColor = color; - this.write(); + Config.set(this.labelColor, color); } public int getHeadlineColor() { - return this.headlineColor; + return this.headlineColor.get(); } public void setHeadlineColor(int color) { - this.headlineColor = color; - this.write(); + Config.set(this.headlineColor, color); } private int getBackgroundRed() { - return this.backgroundRed; + return this.backgroundRed.get(); } public float getBackgroundRedF() @@ -191,13 +137,12 @@ public class ConfigCategorySkin public void setBackgroundRed(int red) { - this.backgroundRed = red; - this.write(); + Config.set(this.backgroundRed, red); } private int getBackgroundGreen() { - return this.backgroundGreen; + return this.backgroundGreen.get(); } public float getBackgroundGreenF() @@ -207,13 +152,12 @@ public class ConfigCategorySkin public void setBackgroundGreen(int green) { - this.backgroundGreen = green; - this.write(); + Config.set(this.backgroundGreen, green); } private int getBackgroundBlue() { - return this.backgroundBlue; + return this.backgroundBlue.get(); } public float getBackgroundBlueF() @@ -223,13 +167,12 @@ public class ConfigCategorySkin public void setBackgroundBlue(int blue) { - this.backgroundBlue = blue; - this.write(); + Config.set(this.backgroundBlue, blue); } private int getButtonRed() { - return this.buttonRed; + return this.buttonRed.get(); } public float getButtonRedF() @@ -239,13 +182,12 @@ public class ConfigCategorySkin public void setButtonRed(int red) { - this.backgroundRed = red; - this.write(); + Config.set(this.backgroundRed, red); } private int getButtonGreen() { - return this.buttonGreen; + return this.buttonGreen.get(); } public float getButtonGreenF() @@ -255,13 +197,12 @@ public class ConfigCategorySkin public void setButtonGreen(int green) { - this.buttonGreen = green; - this.write(); + Config.set(this.buttonGreen, green); } private int getButtonBlue() { - return this.buttonBlue; + return this.buttonBlue.get(); } public float getButtonBlueF() @@ -271,46 +212,42 @@ public class ConfigCategorySkin public void setButtonBlue(int blue) { - this.buttonBlue = blue; - this.write(); + Config.set(this.buttonBlue, blue); } public String getTextureType() { - return this.type; + return this.type.get(); } public void setTextureType(String type) { - this.type = type; - this.write(); + Config.set(this.type, type); } public boolean sharpEdges() { - return this.sharpEdges; + return this.sharpEdges.get(); } public void setSharpEdges(boolean enabled) { - this.sharpEdges = enabled; - this.write(); + Config.set(this.sharpEdges, enabled); } public boolean drawBackground() { - return this.drawBackground; + return this.drawBackground.get(); } public void setDrawBackground(boolean enabled) { - this.drawBackground = enabled; - this.write(); + Config.set(this.drawBackground, enabled); } private int getBackgroundAlpha() { - return this.backgroundAlpha; + return this.backgroundAlpha.get(); } public float getBackgroundAlphaF() @@ -320,13 +257,12 @@ public class ConfigCategorySkin public void setBackgroundAlpha(int alpha) { - this.backgroundAlpha = alpha; - this.write(); + Config.set(this.backgroundAlpha, alpha); } private int getButtonAlpha() { - return this.buttonAlpha; + return this.buttonAlpha.get(); } public float getButtonAlphaF() @@ -336,8 +272,7 @@ public class ConfigCategorySkin public void setButtonAlpha(int alpha) { - this.buttonAlpha = alpha; - this.write(); + Config.set(this.buttonAlpha, alpha); } @OnlyIn(Dist.CLIENT) diff --git a/src/main/java/exopandora/worldhandler/config/ConfigCategorySliders.java b/src/main/java/exopandora/worldhandler/config/ConfigCategorySliders.java index fde8f15..d53eb0d 100644 --- a/src/main/java/exopandora/worldhandler/config/ConfigCategorySliders.java +++ b/src/main/java/exopandora/worldhandler/config/ConfigCategorySliders.java @@ -8,66 +8,56 @@ import net.minecraftforge.common.ForgeConfigSpec.DoubleValue; @OnlyIn(Dist.CLIENT) public class ConfigCategorySliders { - private double maxPotionAmplifier; - private double maxItemEnchantment; - private double maxItemAttributes; - private double maxSummonPotionAmplifier; - private double maxSummonPotionMinutes; - private double maxSummonAttributes; - private double maxExperience; - private double maxPlayerPoints; - private double maxTriggerValue; - - private final DoubleValue valueMaxPotionAmplifier; - private final DoubleValue valueMaxItemEnchantment; - private final DoubleValue valueMaxItemAttributes; - private final DoubleValue valueMaxSummonPotionAmplifier; - private final DoubleValue valueMaxSummonPotionMinutes; - private final DoubleValue valueMaxSummonAttributes; - private final DoubleValue valueMaxExperience; - private final DoubleValue valueMaxPlayerPoints; - private final DoubleValue valueMaxTriggerValue; + private final DoubleValue maxPotionAmplifier; + private final DoubleValue maxItemEnchantment; + private final DoubleValue maxItemAttributes; + private final DoubleValue maxSummonPotionAmplifier; + private final DoubleValue maxSummonPotionMinutes; + private final DoubleValue maxSummonAttributes; + private final DoubleValue maxExperience; + private final DoubleValue maxPlayerPoints; + private final DoubleValue maxTriggerValue; public ConfigCategorySliders(ForgeConfigSpec.Builder builder) { builder.push("sliders"); - this.valueMaxPotionAmplifier = builder + this.maxPotionAmplifier = builder .translation("gui.worldhandler.config.sliders.max_potion_amplifier") .comment("Maximum value for the potion amplifier") .defineInRange("max_potion_amplifier", 100D, 0D, Byte.MAX_VALUE); - this.valueMaxItemEnchantment = builder + this.maxItemEnchantment = builder .translation("gui.worldhandler.config.sliders.max_item_enchantment") .comment("Maximum value for an item enchantment") .defineInRange("max_item_enchantment", 100D, 0D, Integer.MAX_VALUE); - this.valueMaxItemAttributes = builder + this.maxItemAttributes = builder .translation("gui.worldhandler.config.sliders.max_item_attributes") .comment("Maximum value for an item attribute") .defineInRange("max_item_attributes", 100D, 0D, Double.MAX_VALUE); - this.valueMaxSummonPotionAmplifier = builder + this.maxSummonPotionAmplifier = builder .translation("gui.worldhandler.config.sliders.max_summon_potion_amplifier") .comment("Maximum value for the potion amplifier for summon") .defineInRange("max_summon_potion_amplifier", 100D, 0D, Byte.MAX_VALUE); - this.valueMaxSummonPotionMinutes = builder + this.maxSummonPotionMinutes = builder .translation("gui.worldhandler.config.sliders.max_summon_potion_minutes") .comment("Maximum value for the potion duration in minutes for summon") .defineInRange("max_summon_potion_minutes", 100D, 0D, 16000); - this.valueMaxSummonAttributes = builder + this.maxSummonAttributes = builder .translation("gui.worldhandler.config.sliders.max_summon_attributes") .comment("Maximum value for attributes") .defineInRange("max_summon_attributes", 100D, 0D, Double.MAX_VALUE); - this.valueMaxExperience = builder + this.maxExperience = builder .translation("gui.worldhandler.config.sliders.max_experience") .comment("Maximum value for experience") .defineInRange("max_experience", 100D, 0D, 100000D); - this.valueMaxPlayerPoints = builder + this.maxPlayerPoints = builder .translation("gui.worldhandler.config.sliders.max_player_points") .comment("Maximum value for player points") .defineInRange("max_player_points", 100D, 0D, 100000D); - this.valueMaxTriggerValue = builder + this.maxTriggerValue = builder .translation("gui.worldhandler.config.sliders.max_trigger_value") .comment("Maximum value for triggers") .defineInRange("max_trigger_value", 100D, 0D, 100000D); @@ -75,128 +65,93 @@ public class ConfigCategorySliders builder.pop(); } - public void read() - { - this.maxPotionAmplifier = this.valueMaxPotionAmplifier.get(); - this.maxItemEnchantment = this.valueMaxItemEnchantment.get(); - this.maxItemAttributes = this.valueMaxItemAttributes.get(); - this.maxSummonPotionAmplifier = this.valueMaxSummonPotionAmplifier.get(); - this.maxSummonPotionMinutes = this.valueMaxSummonPotionMinutes.get(); - this.maxSummonAttributes = this.valueMaxSummonAttributes.get(); - this.maxExperience = this.valueMaxExperience.get(); - this.maxPlayerPoints = this.valueMaxPlayerPoints.get(); - this.maxTriggerValue = this.valueMaxTriggerValue.get(); - } - - private void write() - { - Config.set(this.valueMaxPotionAmplifier, this.maxPotionAmplifier); - Config.set(this.valueMaxItemEnchantment, this.maxItemEnchantment); - Config.set(this.valueMaxItemAttributes, this.maxItemAttributes); - Config.set(this.valueMaxSummonPotionAmplifier, this.maxSummonPotionAmplifier); - Config.set(this.valueMaxSummonPotionMinutes, this.maxSummonPotionMinutes); - Config.set(this.valueMaxSummonAttributes, this.maxSummonAttributes); - Config.set(this.valueMaxExperience, this.maxExperience); - Config.set(this.valueMaxPlayerPoints, this.maxPlayerPoints); - Config.set(this.valueMaxTriggerValue, this.maxTriggerValue); - } - public double getMaxPotionAmplifier() { - return this.maxPotionAmplifier; + return this.maxPotionAmplifier.get(); } public void setMaxPotionAmplifier(double max) { - this.maxPotionAmplifier = max; - this.write(); + Config.set(this.maxPotionAmplifier, max); } public double getMaxItemEnchantment() { - return this.maxItemEnchantment; + return this.maxItemEnchantment.get(); } public void setMaxItemEnchantment(double max) { - this.maxItemEnchantment = max; - this.write(); + Config.set(this.maxItemEnchantment, max); } public double getMaxItemAttributes() { - return this.maxItemAttributes; + return this.maxItemAttributes.get(); } public void setMaxItemAttributes(double max) { - this.maxItemAttributes = max; - this.write(); + Config.set(this.maxItemAttributes, max); } public double getMaxSummonPotionAmplifier() { - return this.maxSummonPotionAmplifier; + return this.maxSummonPotionAmplifier.get(); } public void setMaxSummonPotionAmplifier(double max) { - this.maxSummonPotionAmplifier = max; - this.write(); + Config.set(this.maxSummonPotionAmplifier, max); } public double getMaxSummonPotionMinutes() { - return this.maxSummonPotionMinutes; + return this.maxSummonPotionMinutes.get(); } public void setMaxSummonPotionMinutes(double max) { - this.maxSummonPotionMinutes = max; - this.write(); + Config.set(this.maxSummonPotionMinutes, max); } public double getMaxSummonAttributes() { - return this.maxSummonAttributes; + return this.maxSummonAttributes.get(); } public void setMaxSummonAttributes(double max) { - this.maxSummonAttributes = max; - this.write(); + Config.set(this.maxSummonAttributes, max); } public double getMaxExperience() { - return this.maxExperience; + return this.maxExperience.get(); } public void setMaxExperience(double max) { - this.maxExperience = max; - this.write(); + Config.set(this.maxExperience, max); } public double getMaxPlayerPoints() { - return this.maxPlayerPoints; + return this.maxPlayerPoints.get(); } public void setMaxPlayerPoints(double max) { - this.maxPlayerPoints = max; - this.write(); + Config.set(this.maxPlayerPoints, max); } public double getMaxTriggerValue() { - return this.maxTriggerValue; + return this.maxTriggerValue.get(); } public void setMaxTriggerValue(double max) { - this.maxTriggerValue = max; - this.write(); + Config.set(this.maxTriggerValue, max); } }