Remove redundant code

This commit is contained in:
Marcel Konrad
2019-11-07 21:35:51 +01:00
parent 261de16dd3
commit a51575c62a
5 changed files with 168 additions and 377 deletions

View File

@@ -48,14 +48,6 @@ public class Config
this.sliders = new ConfigCategorySliders(builder); this.sliders = new ConfigCategorySliders(builder);
} }
public void read()
{
this.getSettings().read();
this.getButcher().read();
this.getSkin().read();
this.getSliders().read();
}
public ConfigCategorySettings getSettings() public ConfigCategorySettings getSettings()
{ {
return this.settings; return this.settings;
@@ -112,7 +104,6 @@ public class Config
{ {
Config.MOD_CONFIG = event.getConfig(); Config.MOD_CONFIG = event.getConfig();
Config.CONFIG_DATA = (CommentedFileConfig) Config.MOD_CONFIG.getConfigData(); 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) if(event.getConfig().getType().equals(Type.CLIENT) && Config.CONFIG_DATA != null)
{ {
Config.CONFIG_DATA.load(); Config.CONFIG_DATA.load();
Config.CLIENT.read();
KeyHandler.updatePosKeys(); KeyHandler.updatePosKeys();
} }
} }

View File

@@ -1,8 +1,10 @@
package exopandora.worldhandler.config; package exopandora.worldhandler.config;
import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import com.google.common.base.Predicates;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.Dist;
@@ -14,68 +16,47 @@ import net.minecraftforge.registries.ForgeRegistries;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public class ConfigCategoryButcher public class ConfigCategoryButcher
{ {
private final List<String> entities = new ArrayList<String>(); private final ConfigValue<List<? extends String>> entities;
private final ConfigValue<List<? extends String>> valueEntities;
public ConfigCategoryButcher(ForgeConfigSpec.Builder builder) public ConfigCategoryButcher(ForgeConfigSpec.Builder builder)
{ {
builder.push("butcher"); builder.push("butcher");
this.valueEntities = builder.defineList("entities", Collections.<String>emptyList(), this::isValid); this.entities = builder.defineList("entities", Collections.<String>emptyList(), this::isValid);
builder.pop(); 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<ResourceLocation> getEntities() public List<ResourceLocation> getEntities()
{ {
List<ResourceLocation> list = new ArrayList<ResourceLocation>(); return this.entities.get().stream().map(ResourceLocation::tryCreate).filter(Predicates.notNull()).collect(Collectors.toList());
for(String entity : this.entities)
{
ResourceLocation resource = ResourceLocation.tryCreate(entity);
if(resource != null)
{
list.add(resource);
}
}
return list;
} }
public boolean containsEntity(ResourceLocation entity) public boolean containsEntity(ResourceLocation entity)
{ {
return this.entities.contains(entity.toString()); return this.getEntities().contains(entity);
} }
public void addEntity(ResourceLocation entity) public void addEntity(ResourceLocation entity)
{ {
if(this.isValid(entity)) if(this.isValid(entity))
{ {
this.entities.add(entity.toString()); @SuppressWarnings("unchecked")
this.write(); List<String> entities = (List<String>) this.entities.get();
entities.add(entity.toString());
Config.set(this.entities, entities);
} }
} }
public boolean removeEntity(ResourceLocation entity) public boolean removeEntity(ResourceLocation entity)
{ {
boolean removed = this.entities.remove(entity.toString()); @SuppressWarnings("unchecked")
List<String> entities = (List<String>) this.entities.get();
boolean removed = entities.remove(entity.toString());
if(removed) if(removed)
{ {
this.write(); Config.set(this.entities, entities);
} }
return removed; return removed;

View File

@@ -12,101 +12,85 @@ import net.minecraftforge.common.ForgeConfigSpec.IntValue;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public class ConfigCategorySettings public class ConfigCategorySettings
{ {
private boolean commandSyntax; private final BooleanValue commandSyntax;
private boolean shortcuts; private final BooleanValue shortcuts;
private boolean shortcutKeys; private final BooleanValue shortcutKeys;
private boolean tooltips; private final BooleanValue tooltips;
private boolean watch; private final BooleanValue watch;
private boolean smoothWatch; private final BooleanValue smoothWatch;
private boolean pause; private final BooleanValue pause;
private boolean customTimes; private final BooleanValue customTimes;
private boolean permissionQuery; private final BooleanValue permissionQuery;
private boolean highlightBlocks; private final BooleanValue highlightBlocks;
private int dawn; private final IntValue dawn;
private int noon; private final IntValue noon;
private int sunset; private final IntValue sunset;
private int midnight; private final IntValue midnight;
private String blockPlacingMode; private final ConfigValue<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<String> valueBlockPlacingMode;
public ConfigCategorySettings(ForgeConfigSpec.Builder builder) public ConfigCategorySettings(ForgeConfigSpec.Builder builder)
{ {
builder.push("settings"); builder.push("settings");
this.valueCommandSyntax = builder this.commandSyntax = builder
.translation("gui.worldhandler.config.settings.command_syntax") .translation("gui.worldhandler.config.settings.command_syntax")
.comment("Whether or not to display the current command at the bottom") .comment("Whether or not to display the current command at the bottom")
.define("command_syntax", false); .define("command_syntax", false);
this.valueShortcuts = builder this.shortcuts = builder
.translation("gui.worldhandler.config.settings.shortcuts") .translation("gui.worldhandler.config.settings.shortcuts")
.comment("Whether or not to display a row of quick access buttons at the top") .comment("Whether or not to display a row of quick access buttons at the top")
.define("shortcuts", false); .define("shortcuts", false);
this.valueShortcutKeys = builder this.shortcutKeys = builder
.translation("gui.worldhandler.config.settings.key_shortcuts") .translation("gui.worldhandler.config.settings.key_shortcuts")
.comment("Whether or not to enable button keys for pos1 and pos2") .comment("Whether or not to enable button keys for pos1 and pos2")
.define("key_shortcuts", false); .define("key_shortcuts", false);
this.valueTooltips = builder this.tooltips = builder
.translation("gui.worldhandler.config.settings.tooltips") .translation("gui.worldhandler.config.settings.tooltips")
.comment("Whether or not to display tooltips for buttons") .comment("Whether or not to display tooltips for buttons")
.define("tooltips", true); .define("tooltips", true);
this.valueWatch = builder this.watch = builder
.translation("gui.worldhandler.config.settings.watch") .translation("gui.worldhandler.config.settings.watch")
.comment("Whether or not to display a watch") .comment("Whether or not to display a watch")
.define("watch", true); .define("watch", true);
this.valueSmoothWatch = builder this.smoothWatch = builder
.translation("gui.worldhandler.config.settings.smooth_watch") .translation("gui.worldhandler.config.settings.smooth_watch")
.comment("Whether or not the watch pointers move smoothly") .comment("Whether or not the watch pointers move smoothly")
.define("smooth_watch", true); .define("smooth_watch", true);
this.valuePause = builder this.pause = builder
.translation("gui.worldhandler.config.settings.pause_game") .translation("gui.worldhandler.config.settings.pause_game")
.comment("Whether or not to pause the game when the gui is opened") .comment("Whether or not to pause the game when the gui is opened")
.define("pause_game", false); .define("pause_game", false);
this.valueCustomTimes = builder this.customTimes = builder
.translation("gui.worldhandler.config.settings.custom_times") .translation("gui.worldhandler.config.settings.custom_times")
.comment("Whether or not to use the custom times") .comment("Whether or not to use the custom times")
.define("custom_times", false); .define("custom_times", false);
this.valuePermissionQuery = builder this.permissionQuery = builder
.translation("gui.worldhandler.config.settings.permission_query") .translation("gui.worldhandler.config.settings.permission_query")
.comment("Whether or not the permission query is enabled") .comment("Whether or not the permission query is enabled")
.define("permission_query", true); .define("permission_query", true);
this.valueHighlightBlocks = builder this.highlightBlocks = builder
.translation("gui.worldhandler.config.settings.highlight_blocks") .translation("gui.worldhandler.config.settings.highlight_blocks")
.comment("Whether or not selected blocks will be highlighted") .comment("Whether or not selected blocks will be highlighted")
.define("highlight_blocks", true); .define("highlight_blocks", true);
this.valueDawn = builder this.dawn = builder
.translation("gui.worldhandler.config.settings.custom_time_dawn") .translation("gui.worldhandler.config.settings.custom_time_dawn")
.comment("Ticks upon dawn") .comment("Ticks upon dawn")
.defineInRange("custom_time_dawn", 1000, 0, 24000); .defineInRange("custom_time_dawn", 1000, 0, 24000);
this.valueNoon = builder this.noon = builder
.translation("gui.worldhandler.config.settings.custom_time_noon") .translation("gui.worldhandler.config.settings.custom_time_noon")
.comment("Ticks upon noon") .comment("Ticks upon noon")
.defineInRange("custom_time_noon", 6000, 0, 24000); .defineInRange("custom_time_noon", 6000, 0, 24000);
this.valueSunset = builder this.sunset = builder
.translation("gui.worldhandler.config.settings.custom_time_sunset") .translation("gui.worldhandler.config.settings.custom_time_sunset")
.comment("Ticks upon sunset") .comment("Ticks upon sunset")
.defineInRange("custom_time_sunset", 12500, 0, 24000); .defineInRange("custom_time_sunset", 12500, 0, 24000);
this.valueMidnight = builder this.midnight = builder
.translation("gui.worldhandler.config.settings.custom_time_midnight") .translation("gui.worldhandler.config.settings.custom_time_midnight")
.comment("Ticks upon midnight") .comment("Ticks upon midnight")
.defineInRange("custom_time_midnight", 18000, 0, 24000); .defineInRange("custom_time_midnight", 18000, 0, 24000);
this.valueBlockPlacingMode = builder this.blockPlacingMode = builder
.translation("gui.worldhandler.config.settings.block_placing_mode") .translation("gui.worldhandler.config.settings.block_placing_mode")
.comment("Block placing mode (keep, replace, destroy)") .comment("Block placing mode (keep, replace, destroy)")
.defineInList("block_placing_mode", "keep", Arrays.asList("keep", "replace", "destroy")); .defineInList("block_placing_mode", "keep", Arrays.asList("keep", "replace", "destroy"));
@@ -114,206 +98,153 @@ public class ConfigCategorySettings
builder.pop(); 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() public boolean commandSyntax()
{ {
return this.commandSyntax; return this.commandSyntax.get();
} }
public void setCommandSyntax(boolean enabled) public void setCommandSyntax(boolean enabled)
{ {
this.commandSyntax = enabled; Config.set(this.commandSyntax, enabled);
this.write();
} }
public boolean shortcuts() public boolean shortcuts()
{ {
return this.shortcuts; return this.shortcuts.get();
} }
public void setShortcuts(boolean enabled) public void setShortcuts(boolean enabled)
{ {
this.shortcuts = enabled; Config.set(this.shortcuts, enabled);
this.write();
} }
public boolean shortcutKeys() public boolean shortcutKeys()
{ {
return this.shortcutKeys; return this.shortcutKeys.get();
} }
public void setShortcutKeys(boolean enabled) public void setShortcutKeys(boolean enabled)
{ {
this.shortcutKeys = enabled; Config.set(this.shortcutKeys, enabled);
this.write();
} }
public boolean tooltips() public boolean tooltips()
{ {
return this.tooltips; return this.tooltips.get();
} }
public void setTooltips(boolean enabled) public void setTooltips(boolean enabled)
{ {
this.tooltips = enabled; Config.set(this.tooltips, enabled);
this.write();
} }
public boolean watch() public boolean watch()
{ {
return this.watch; return this.watch.get();
} }
public void setWatch(boolean enabled) public void setWatch(boolean enabled)
{ {
this.watch = enabled; Config.set(this.watch, enabled);
this.write();
} }
public boolean smoothWatch() public boolean smoothWatch()
{ {
return this.smoothWatch; return this.smoothWatch.get();
} }
public void setSmoothWatch(boolean enabled) public void setSmoothWatch(boolean enabled)
{ {
this.smoothWatch = enabled; Config.set(this.smoothWatch, enabled);
this.write();
} }
public boolean pause() public boolean pause()
{ {
return this.pause; return this.pause.get();
} }
public void setPause(boolean enabled) public void setPause(boolean enabled)
{ {
this.pause = enabled; Config.set(this.pause, enabled);
this.write();
} }
public boolean customTimes() public boolean customTimes()
{ {
return this.customTimes; return this.customTimes.get();
} }
public void setCustomTimes(boolean enabled) public void setCustomTimes(boolean enabled)
{ {
this.customTimes = enabled; Config.set(this.customTimes, enabled);
this.write();
} }
public boolean permissionQuery() public boolean permissionQuery()
{ {
return this.permissionQuery; return this.permissionQuery.get();
} }
public void setPermissionQuery(boolean enabled) public void setPermissionQuery(boolean enabled)
{ {
this.permissionQuery = enabled; Config.set(this.permissionQuery, enabled);
this.write();
} }
public boolean highlightBlocks() public boolean highlightBlocks()
{ {
return this.highlightBlocks; return this.highlightBlocks.get();
} }
public void setHighlightBlocks(boolean enabled) public void setHighlightBlocks(boolean enabled)
{ {
this.highlightBlocks = enabled; Config.set(this.highlightBlocks, enabled);
this.write();
} }
public int getDawn() public int getDawn()
{ {
return this.dawn; return this.dawn.get();
} }
public void setDawn(int ticks) public void setDawn(int ticks)
{ {
this.dawn = ticks; Config.set(this.dawn, ticks);
this.write();
} }
public int getNoon() public int getNoon()
{ {
return this.noon; return this.noon.get();
} }
public void setNoon(int ticks) public void setNoon(int ticks)
{ {
this.noon = ticks; Config.set(this.noon, ticks);
this.write();
} }
public int getSunset() public int getSunset()
{ {
return this.sunset; return this.sunset.get();
} }
public void setSunset(int ticks) public void setSunset(int ticks)
{ {
this.sunset = ticks; Config.set(this.sunset, ticks);
this.write();
} }
public int getMidnight() public int getMidnight()
{ {
return this.midnight; return this.midnight.get();
} }
public void setMidnight(int ticks) public void setMidnight(int ticks)
{ {
this.midnight = ticks; Config.set(this.midnight, ticks);
this.write();
} }
public String getBlockPlacingMode() public String getBlockPlacingMode()
{ {
return this.blockPlacingMode; return this.blockPlacingMode.get();
} }
public void setBlockPlacingMode(String mode) public void setBlockPlacingMode(String mode)
{ {
this.blockPlacingMode = mode; Config.set(this.blockPlacingMode, mode);
this.write();
} }
} }

View File

@@ -12,97 +12,82 @@ import net.minecraftforge.common.ForgeConfigSpec.IntValue;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public class ConfigCategorySkin public class ConfigCategorySkin
{ {
private EnumIconSize iconSize; private final ConfigValue<EnumIconSize> iconSize;
private int labelColor; private final IntValue labelColor;
private int headlineColor; private final IntValue headlineColor;
private int backgroundRed; private final IntValue backgroundRed;
private int backgroundGreen; private final IntValue backgroundGreen;
private int backgroundBlue; private final IntValue backgroundBlue;
private int backgroundAlpha; private final IntValue backgroundAlpha;
private int buttonRed; private final IntValue buttonRed;
private int buttonGreen; private final IntValue buttonGreen;
private int buttonBlue; private final IntValue buttonBlue;
private int buttonAlpha; private final IntValue buttonAlpha;
private String type; private final ConfigValue<String> type;
private boolean sharpEdges; private final BooleanValue sharpEdges;
private boolean drawBackground; private final BooleanValue drawBackground;
private final ConfigValue<EnumIconSize> 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<String> valueType;
private final BooleanValue valueSharpEdges;
private final BooleanValue valueDrawBackground;
public ConfigCategorySkin(ForgeConfigSpec.Builder builder) public ConfigCategorySkin(ForgeConfigSpec.Builder builder)
{ {
builder.push("skin"); builder.push("skin");
this.valueIconSize = builder this.iconSize = builder
.translation("gui.worldhandler.config.skin.icon_size") .translation("gui.worldhandler.config.skin.icon_size")
.comment("Size of the icons") .comment("Size of the icons")
.defineEnum("icon_size", EnumIconSize.x16, EnumIconSize.values()); .defineEnum("icon_size", EnumIconSize.x16, EnumIconSize.values());
this.valueLabelColor = builder this.labelColor = builder
.translation("gui.worldhandler.config.skin.label_color") .translation("gui.worldhandler.config.skin.label_color")
.comment("Label color") .comment("Label color")
.defineInRange("label_color", 0x1F1F1F, 0x80000000, 0x7FFFFFFF); .defineInRange("label_color", 0x1F1F1F, 0x80000000, 0x7FFFFFFF);
this.valueHeadlineColor = builder this.headlineColor = builder
.translation("gui.worldhandler.config.skin.headline_color") .translation("gui.worldhandler.config.skin.headline_color")
.comment("Headline color") .comment("Headline color")
.defineInRange("headline_color", 0x4F4F4F, 0x80000000, 0x7FFFFFFF); .defineInRange("headline_color", 0x4F4F4F, 0x80000000, 0x7FFFFFFF);
this.valueBackgroundRed = builder this.backgroundRed = builder
.translation("gui.worldhandler.config.skin.background_red") .translation("gui.worldhandler.config.skin.background_red")
.comment("Background red") .comment("Background red")
.defineInRange("background_red", 255, 0, 255); .defineInRange("background_red", 255, 0, 255);
this.valueBackgroundGreen = builder this.backgroundGreen = builder
.translation("gui.worldhandler.config.skin.background_green") .translation("gui.worldhandler.config.skin.background_green")
.comment("Background green") .comment("Background green")
.defineInRange("background_green", 255, 0, 255); .defineInRange("background_green", 255, 0, 255);
this.valueBackgroundBlue = builder this.backgroundBlue = builder
.translation("gui.worldhandler.config.skin.background_blue") .translation("gui.worldhandler.config.skin.background_blue")
.comment("Background blue") .comment("Background blue")
.defineInRange("background_blue", 255, 0, 255); .defineInRange("background_blue", 255, 0, 255);
this.valueBackgroundAlpha = builder this.backgroundAlpha = builder
.translation("gui.worldhandler.config.skin.background_alpha") .translation("gui.worldhandler.config.skin.background_alpha")
.comment("Background alpha") .comment("Background alpha")
.defineInRange("background_alpha", 255, 0, 255); .defineInRange("background_alpha", 255, 0, 255);
this.valueButtonRed = builder this.buttonRed = builder
.translation("gui.worldhandler.config.skin.button_red") .translation("gui.worldhandler.config.skin.button_red")
.comment("Button eed") .comment("Button red")
.defineInRange("button_red", 255, 0, 255); .defineInRange("button_red", 255, 0, 255);
this.valueButtonGreen = builder this.buttonGreen = builder
.translation("gui.worldhandler.config.skin.button_green") .translation("gui.worldhandler.config.skin.button_green")
.comment("Button green") .comment("Button green")
.defineInRange("button_green", 255, 0, 255); .defineInRange("button_green", 255, 0, 255);
this.valueButtonBlue = builder this.buttonBlue = builder
.translation("gui.worldhandler.config.skin.button_blue") .translation("gui.worldhandler.config.skin.button_blue")
.comment("Button blue") .comment("Button blue")
.defineInRange("button_blue", 255, 0, 255); .defineInRange("button_blue", 255, 0, 255);
this.valueButtonAlpha = builder this.buttonAlpha = builder
.translation("gui.worldhandler.config.skin.button_alpha") .translation("gui.worldhandler.config.skin.button_alpha")
.comment("Button alpha") .comment("Button alpha")
.defineInRange("button_alpha", 255, 0, 255); .defineInRange("button_alpha", 255, 0, 255);
this.valueType = builder this.type = builder
.translation("gui.worldhandler.config.skin.textures") .translation("gui.worldhandler.config.skin.textures")
.comment("Background texture (resourcepack, vanilla)") .comment("Background texture (resourcepack, vanilla)")
.defineInList("textures", "resourcepack", Arrays.asList("resourcepack", "vanilla")); .defineInList("textures", "resourcepack", Arrays.asList("resourcepack", "vanilla"));
this.valueSharpEdges = builder this.sharpEdges = builder
.translation("gui.worldhandler.config.settings.sharp_tab_edges") .translation("gui.worldhandler.config.settings.sharp_tab_edges")
.comment("Whether or not the gui has sharp or smooth tab edges") .comment("Whether or not the gui has sharp or smooth tab edges")
.define("sharp_tab_edges", false); .define("sharp_tab_edges", false);
this.valueDrawBackground = builder this.drawBackground = builder
.translation("gui.worldhandler.config.settings.draw_background") .translation("gui.worldhandler.config.settings.draw_background")
.comment("Whether or not to enable background drawing") .comment("Whether or not to enable background drawing")
.define("draw_background", true); .define("draw_background", true);
@@ -110,78 +95,39 @@ public class ConfigCategorySkin
builder.pop(); 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() public EnumIconSize getIconSize()
{ {
return this.iconSize; return this.iconSize.get();
} }
public void setIconSize(EnumIconSize size) public void setIconSize(EnumIconSize size)
{ {
this.iconSize = size; Config.set(this.iconSize, size);
this.write();
} }
public int getLabelColor() public int getLabelColor()
{ {
return this.labelColor; return this.labelColor.get();
} }
public void setLabelColor(int color) public void setLabelColor(int color)
{ {
this.labelColor = color; Config.set(this.labelColor, color);
this.write();
} }
public int getHeadlineColor() public int getHeadlineColor()
{ {
return this.headlineColor; return this.headlineColor.get();
} }
public void setHeadlineColor(int color) public void setHeadlineColor(int color)
{ {
this.headlineColor = color; Config.set(this.headlineColor, color);
this.write();
} }
private int getBackgroundRed() private int getBackgroundRed()
{ {
return this.backgroundRed; return this.backgroundRed.get();
} }
public float getBackgroundRedF() public float getBackgroundRedF()
@@ -191,13 +137,12 @@ public class ConfigCategorySkin
public void setBackgroundRed(int red) public void setBackgroundRed(int red)
{ {
this.backgroundRed = red; Config.set(this.backgroundRed, red);
this.write();
} }
private int getBackgroundGreen() private int getBackgroundGreen()
{ {
return this.backgroundGreen; return this.backgroundGreen.get();
} }
public float getBackgroundGreenF() public float getBackgroundGreenF()
@@ -207,13 +152,12 @@ public class ConfigCategorySkin
public void setBackgroundGreen(int green) public void setBackgroundGreen(int green)
{ {
this.backgroundGreen = green; Config.set(this.backgroundGreen, green);
this.write();
} }
private int getBackgroundBlue() private int getBackgroundBlue()
{ {
return this.backgroundBlue; return this.backgroundBlue.get();
} }
public float getBackgroundBlueF() public float getBackgroundBlueF()
@@ -223,13 +167,12 @@ public class ConfigCategorySkin
public void setBackgroundBlue(int blue) public void setBackgroundBlue(int blue)
{ {
this.backgroundBlue = blue; Config.set(this.backgroundBlue, blue);
this.write();
} }
private int getButtonRed() private int getButtonRed()
{ {
return this.buttonRed; return this.buttonRed.get();
} }
public float getButtonRedF() public float getButtonRedF()
@@ -239,13 +182,12 @@ public class ConfigCategorySkin
public void setButtonRed(int red) public void setButtonRed(int red)
{ {
this.backgroundRed = red; Config.set(this.backgroundRed, red);
this.write();
} }
private int getButtonGreen() private int getButtonGreen()
{ {
return this.buttonGreen; return this.buttonGreen.get();
} }
public float getButtonGreenF() public float getButtonGreenF()
@@ -255,13 +197,12 @@ public class ConfigCategorySkin
public void setButtonGreen(int green) public void setButtonGreen(int green)
{ {
this.buttonGreen = green; Config.set(this.buttonGreen, green);
this.write();
} }
private int getButtonBlue() private int getButtonBlue()
{ {
return this.buttonBlue; return this.buttonBlue.get();
} }
public float getButtonBlueF() public float getButtonBlueF()
@@ -271,46 +212,42 @@ public class ConfigCategorySkin
public void setButtonBlue(int blue) public void setButtonBlue(int blue)
{ {
this.buttonBlue = blue; Config.set(this.buttonBlue, blue);
this.write();
} }
public String getTextureType() public String getTextureType()
{ {
return this.type; return this.type.get();
} }
public void setTextureType(String type) public void setTextureType(String type)
{ {
this.type = type; Config.set(this.type, type);
this.write();
} }
public boolean sharpEdges() public boolean sharpEdges()
{ {
return this.sharpEdges; return this.sharpEdges.get();
} }
public void setSharpEdges(boolean enabled) public void setSharpEdges(boolean enabled)
{ {
this.sharpEdges = enabled; Config.set(this.sharpEdges, enabled);
this.write();
} }
public boolean drawBackground() public boolean drawBackground()
{ {
return this.drawBackground; return this.drawBackground.get();
} }
public void setDrawBackground(boolean enabled) public void setDrawBackground(boolean enabled)
{ {
this.drawBackground = enabled; Config.set(this.drawBackground, enabled);
this.write();
} }
private int getBackgroundAlpha() private int getBackgroundAlpha()
{ {
return this.backgroundAlpha; return this.backgroundAlpha.get();
} }
public float getBackgroundAlphaF() public float getBackgroundAlphaF()
@@ -320,13 +257,12 @@ public class ConfigCategorySkin
public void setBackgroundAlpha(int alpha) public void setBackgroundAlpha(int alpha)
{ {
this.backgroundAlpha = alpha; Config.set(this.backgroundAlpha, alpha);
this.write();
} }
private int getButtonAlpha() private int getButtonAlpha()
{ {
return this.buttonAlpha; return this.buttonAlpha.get();
} }
public float getButtonAlphaF() public float getButtonAlphaF()
@@ -336,8 +272,7 @@ public class ConfigCategorySkin
public void setButtonAlpha(int alpha) public void setButtonAlpha(int alpha)
{ {
this.buttonAlpha = alpha; Config.set(this.buttonAlpha, alpha);
this.write();
} }
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)

View File

@@ -8,66 +8,56 @@ import net.minecraftforge.common.ForgeConfigSpec.DoubleValue;
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public class ConfigCategorySliders public class ConfigCategorySliders
{ {
private double maxPotionAmplifier; private final DoubleValue maxPotionAmplifier;
private double maxItemEnchantment; private final DoubleValue maxItemEnchantment;
private double maxItemAttributes; private final DoubleValue maxItemAttributes;
private double maxSummonPotionAmplifier; private final DoubleValue maxSummonPotionAmplifier;
private double maxSummonPotionMinutes; private final DoubleValue maxSummonPotionMinutes;
private double maxSummonAttributes; private final DoubleValue maxSummonAttributes;
private double maxExperience; private final DoubleValue maxExperience;
private double maxPlayerPoints; private final DoubleValue maxPlayerPoints;
private double maxTriggerValue; private final DoubleValue 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;
public ConfigCategorySliders(ForgeConfigSpec.Builder builder) public ConfigCategorySliders(ForgeConfigSpec.Builder builder)
{ {
builder.push("sliders"); builder.push("sliders");
this.valueMaxPotionAmplifier = builder this.maxPotionAmplifier = builder
.translation("gui.worldhandler.config.sliders.max_potion_amplifier") .translation("gui.worldhandler.config.sliders.max_potion_amplifier")
.comment("Maximum value for the potion amplifier") .comment("Maximum value for the potion amplifier")
.defineInRange("max_potion_amplifier", 100D, 0D, Byte.MAX_VALUE); .defineInRange("max_potion_amplifier", 100D, 0D, Byte.MAX_VALUE);
this.valueMaxItemEnchantment = builder this.maxItemEnchantment = builder
.translation("gui.worldhandler.config.sliders.max_item_enchantment") .translation("gui.worldhandler.config.sliders.max_item_enchantment")
.comment("Maximum value for an item enchantment") .comment("Maximum value for an item enchantment")
.defineInRange("max_item_enchantment", 100D, 0D, Integer.MAX_VALUE); .defineInRange("max_item_enchantment", 100D, 0D, Integer.MAX_VALUE);
this.valueMaxItemAttributes = builder this.maxItemAttributes = builder
.translation("gui.worldhandler.config.sliders.max_item_attributes") .translation("gui.worldhandler.config.sliders.max_item_attributes")
.comment("Maximum value for an item attribute") .comment("Maximum value for an item attribute")
.defineInRange("max_item_attributes", 100D, 0D, Double.MAX_VALUE); .defineInRange("max_item_attributes", 100D, 0D, Double.MAX_VALUE);
this.valueMaxSummonPotionAmplifier = builder this.maxSummonPotionAmplifier = builder
.translation("gui.worldhandler.config.sliders.max_summon_potion_amplifier") .translation("gui.worldhandler.config.sliders.max_summon_potion_amplifier")
.comment("Maximum value for the potion amplifier for summon") .comment("Maximum value for the potion amplifier for summon")
.defineInRange("max_summon_potion_amplifier", 100D, 0D, Byte.MAX_VALUE); .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") .translation("gui.worldhandler.config.sliders.max_summon_potion_minutes")
.comment("Maximum value for the potion duration in minutes for summon") .comment("Maximum value for the potion duration in minutes for summon")
.defineInRange("max_summon_potion_minutes", 100D, 0D, 16000); .defineInRange("max_summon_potion_minutes", 100D, 0D, 16000);
this.valueMaxSummonAttributes = builder this.maxSummonAttributes = builder
.translation("gui.worldhandler.config.sliders.max_summon_attributes") .translation("gui.worldhandler.config.sliders.max_summon_attributes")
.comment("Maximum value for attributes") .comment("Maximum value for attributes")
.defineInRange("max_summon_attributes", 100D, 0D, Double.MAX_VALUE); .defineInRange("max_summon_attributes", 100D, 0D, Double.MAX_VALUE);
this.valueMaxExperience = builder this.maxExperience = builder
.translation("gui.worldhandler.config.sliders.max_experience") .translation("gui.worldhandler.config.sliders.max_experience")
.comment("Maximum value for experience") .comment("Maximum value for experience")
.defineInRange("max_experience", 100D, 0D, 100000D); .defineInRange("max_experience", 100D, 0D, 100000D);
this.valueMaxPlayerPoints = builder this.maxPlayerPoints = builder
.translation("gui.worldhandler.config.sliders.max_player_points") .translation("gui.worldhandler.config.sliders.max_player_points")
.comment("Maximum value for player points") .comment("Maximum value for player points")
.defineInRange("max_player_points", 100D, 0D, 100000D); .defineInRange("max_player_points", 100D, 0D, 100000D);
this.valueMaxTriggerValue = builder this.maxTriggerValue = builder
.translation("gui.worldhandler.config.sliders.max_trigger_value") .translation("gui.worldhandler.config.sliders.max_trigger_value")
.comment("Maximum value for triggers") .comment("Maximum value for triggers")
.defineInRange("max_trigger_value", 100D, 0D, 100000D); .defineInRange("max_trigger_value", 100D, 0D, 100000D);
@@ -75,128 +65,93 @@ public class ConfigCategorySliders
builder.pop(); 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() public double getMaxPotionAmplifier()
{ {
return this.maxPotionAmplifier; return this.maxPotionAmplifier.get();
} }
public void setMaxPotionAmplifier(double max) public void setMaxPotionAmplifier(double max)
{ {
this.maxPotionAmplifier = max; Config.set(this.maxPotionAmplifier, max);
this.write();
} }
public double getMaxItemEnchantment() public double getMaxItemEnchantment()
{ {
return this.maxItemEnchantment; return this.maxItemEnchantment.get();
} }
public void setMaxItemEnchantment(double max) public void setMaxItemEnchantment(double max)
{ {
this.maxItemEnchantment = max; Config.set(this.maxItemEnchantment, max);
this.write();
} }
public double getMaxItemAttributes() public double getMaxItemAttributes()
{ {
return this.maxItemAttributes; return this.maxItemAttributes.get();
} }
public void setMaxItemAttributes(double max) public void setMaxItemAttributes(double max)
{ {
this.maxItemAttributes = max; Config.set(this.maxItemAttributes, max);
this.write();
} }
public double getMaxSummonPotionAmplifier() public double getMaxSummonPotionAmplifier()
{ {
return this.maxSummonPotionAmplifier; return this.maxSummonPotionAmplifier.get();
} }
public void setMaxSummonPotionAmplifier(double max) public void setMaxSummonPotionAmplifier(double max)
{ {
this.maxSummonPotionAmplifier = max; Config.set(this.maxSummonPotionAmplifier, max);
this.write();
} }
public double getMaxSummonPotionMinutes() public double getMaxSummonPotionMinutes()
{ {
return this.maxSummonPotionMinutes; return this.maxSummonPotionMinutes.get();
} }
public void setMaxSummonPotionMinutes(double max) public void setMaxSummonPotionMinutes(double max)
{ {
this.maxSummonPotionMinutes = max; Config.set(this.maxSummonPotionMinutes, max);
this.write();
} }
public double getMaxSummonAttributes() public double getMaxSummonAttributes()
{ {
return this.maxSummonAttributes; return this.maxSummonAttributes.get();
} }
public void setMaxSummonAttributes(double max) public void setMaxSummonAttributes(double max)
{ {
this.maxSummonAttributes = max; Config.set(this.maxSummonAttributes, max);
this.write();
} }
public double getMaxExperience() public double getMaxExperience()
{ {
return this.maxExperience; return this.maxExperience.get();
} }
public void setMaxExperience(double max) public void setMaxExperience(double max)
{ {
this.maxExperience = max; Config.set(this.maxExperience, max);
this.write();
} }
public double getMaxPlayerPoints() public double getMaxPlayerPoints()
{ {
return this.maxPlayerPoints; return this.maxPlayerPoints.get();
} }
public void setMaxPlayerPoints(double max) public void setMaxPlayerPoints(double max)
{ {
this.maxPlayerPoints = max; Config.set(this.maxPlayerPoints, max);
this.write();
} }
public double getMaxTriggerValue() public double getMaxTriggerValue()
{ {
return this.maxTriggerValue; return this.maxTriggerValue.get();
} }
public void setMaxTriggerValue(double max) public void setMaxTriggerValue(double max)
{ {
this.maxTriggerValue = max; Config.set(this.maxTriggerValue, max);
this.write();
} }
} }