From c5041de5d4e19cee4423bf85ceeb765b06ab8ff8 Mon Sep 17 00:00:00 2001 From: coolGi Date: Sun, 16 Jul 2023 23:07:14 +0930 Subject: [PATCH 1/5] Added proper clamping so values don't get out of range --- .../distanthorizons/core/config/Config.java | 4 +- .../core/config/NumberUtil.java | 38 +++++++++ .../core/config/file/ConfigFileHandling.java | 10 +-- .../core/config/types/ConfigEntry.java | 78 +++++++++++++++---- 4 files changed, 108 insertions(+), 22 deletions(-) create mode 100644 core/src/main/java/com/seibel/distanthorizons/core/config/NumberUtil.java diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java b/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java index c3c27afc0..d76f23d19 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java @@ -51,7 +51,7 @@ import java.util.*; * Otherwise, you will have issues where only some of the config entries will exist when your listener is created. * * @author coolGi - * @version 2023-6-12 + * @version 2023-7-16 */ public class Config @@ -456,7 +456,7 @@ public class Config .build(); public static ConfigEntry noiseSteps = new ConfigEntry.Builder() - .setMinDefaultMax(0, 4, null) + .setMinDefaultMax(1, 4, null) .comment("" + "How many steps of noise should be applied to LODs?") .build(); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/NumberUtil.java b/core/src/main/java/com/seibel/distanthorizons/core/config/NumberUtil.java new file mode 100644 index 000000000..9d63ce909 --- /dev/null +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/NumberUtil.java @@ -0,0 +1,38 @@ +package com.seibel.distanthorizons.core.config; + +import java.util.HashMap; +import java.util.Map; + +/** + * Gets the minimum or maximum values of a given type + * + * @author coolGi + * @version 2023-7-16 + */ +// TODO: Should this be moved out of here into somewhere like the util section +public class NumberUtil { + // Is there no better way of doing this? + public static Map minValues = new HashMap() {{ + put(Byte.class, Byte.MIN_VALUE); + put(Short.class, Short.MIN_VALUE); + put(Integer.class, Integer.MIN_VALUE); + put(Long.class, Long.MIN_VALUE); + put(Double.class, Double.MIN_VALUE); + put(Float.class, Float.MIN_VALUE); + }}; + public static Map maxValues = new HashMap() {{ + put(Byte.class, Byte.MAX_VALUE); + put(Short.class, Short.MAX_VALUE); + put(Integer.class, Integer.MAX_VALUE); + put(Long.class, Long.MAX_VALUE); + put(Double.class, Double.MAX_VALUE); + put(Float.class, Float.MAX_VALUE); + }}; + + public static Number getMinimum(Class c) { + return minValues.get(c); + } + public static Number getMaximum(Class c) { + return maxValues.get(c); + } +} diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/file/ConfigFileHandling.java b/core/src/main/java/com/seibel/distanthorizons/core/config/file/ConfigFileHandling.java index 2f51a9571..0cb1aaa2a 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/file/ConfigFileHandling.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/file/ConfigFileHandling.java @@ -17,7 +17,7 @@ import java.nio.file.Path; * Handles reading and writing config files. * * @author coolGi - * @version 2022-9-9 + * @version 2023-7-16 */ public class ConfigFileHandling { private static final Logger LOGGER = ConfigBase.LOGGER; @@ -136,7 +136,7 @@ public class ConfigFileHandling { if (workConfig.contains(entry.getNameWCategory())) { try { if (entry.getType().isEnum()) { - entry.setWithoutSaving((T) ( workConfig.getEnum(entry.getNameWCategory(), (Class) entry.getType()) )); + entry.setWithoutSaving((T) ( workConfig.getEnum(entry.getNameWCategory(), (Class) entry.getType()))); return; } if (ConfigTypeConverters.convertObjects.containsKey(entry.getType())) { @@ -146,11 +146,7 @@ public class ConfigFileHandling { if (entry.getType() == workConfig.get(entry.getNameWCategory()).getClass()) { // If the types are the same entry.setWithoutSaving((T) workConfig.get(entry.getNameWCategory())); - - if (entry.isValid() == 0) return; - else if (entry.isValid() == -1) entry.setWithoutSaving(entry.getMin()); - else if (entry.isValid() == 1) entry.setWithoutSaving(entry.getMax()); - return; + entry.clampWithinRange(); } LOGGER.warn("Entry ["+ entry.getNameWCategory() +"] is invalid. Expected " + entry.getType() + " but got " + workConfig.get(entry.getNameWCategory()).getClass() + ". Using default value."); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigEntry.java b/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigEntry.java index 6aa4b9d28..56f2953cb 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigEntry.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigEntry.java @@ -1,6 +1,7 @@ package com.seibel.distanthorizons.core.config.types; +import com.seibel.distanthorizons.core.config.NumberUtil; import com.seibel.distanthorizons.core.config.listeners.IConfigListener; import com.seibel.distanthorizons.core.config.types.enums.EConfigEntryAppearance; import com.seibel.distanthorizons.core.config.types.enums.EConfigEntryPerformance; @@ -14,7 +15,7 @@ import java.util.Arrays; * for types that are not supported by it look in ConfigBase * * @author coolGi - * @version 2022-5-26 + * @version 2023-7-16 */ public class ConfigEntry extends AbstractConfigType> implements IConfigEntry { @@ -41,8 +42,7 @@ public class ConfigEntry extends AbstractConfigType> implem super(appearance, value); this.defaultValue = value; this.comment = comment; - this.min = min; - this.max = max; + this.setMinMax(min, max); this.allowApiOverride = allowApiOverride; this.performance = performance; this.listenerList = listenerList; @@ -104,19 +104,47 @@ public class ConfigEntry extends AbstractConfigType> implem public T getMin() { return this.min; } /** Sets the min value */ @Override - public void setMin(T newMin) { this.min = newMin; } + @SuppressWarnings("unchecked") // Suppress due to its always safe + public void setMin(T newMin) { + if (newMin == null) + newMin = (T) NumberUtil.getMinimum(newMin.getClass()); + this.min = newMin; + } /** Gets the max value */ @Override public T getMax() { return this.max; } /** Sets the max value */ @Override - public void setMax(T newMax) { this.max = newMax; } - /** Sets the min and max in 1 setter */ + @SuppressWarnings("unchecked") // Suppress due to its always safe + public void setMax(T newMax) { + if (newMax == null) + newMax = (T) NumberUtil.getMinimum(newMax.getClass()); + this.max = newMax; + } + /** Sets the min and max within a single setter */ @Override - public void setMinMax(T newMin, T newMax) - { - this.max = newMin; - this.min = newMax; + public void setMinMax(T newMin, T newMax) { + this.setMin(newMin); + this.setMax(newMax); + } + + /** + * Clamps the value within the set range + * @apiNote This does not save the value + */ + public void clampWithinRange() { this.clampWithinRange(this.min, this.max); } + /** + * Clamps the value within a set range + * + * @param min The minimum that the value can be + * @param max The maximum that the value can be + * @apiNote This does not save the value + */ + @SuppressWarnings("unchecked") // Suppress due to its always safe + public void clampWithinRange(T min, T max) { + byte validness = this.isValid(min, max); + if (validness == -1) this.value = (T) NumberUtil.getMinimum(min.getClass()); + if (validness == 1) this.value = (T) NumberUtil.getMinimum(max.getClass()); } @Override @@ -150,17 +178,41 @@ public class ConfigEntry extends AbstractConfigType> implem *

-1 == number too low */ @Override - public byte isValid() { return isValid(this.value); } + public byte isValid() { return isValid(this.value, this.min, this.max); } /** * Checks if a new value is valid * + * @param value Value that is being checked whether valid * @return 0 == valid *

2 == invalid *

1 == number too high *

-1 == number too low */ - @Override - public byte isValid(T value) { + @Override + public byte isValid(T value) { return this.isValid(value, this.min, this.max); } + /** + * Checks if a new value is valid + * + * @param min The minimum that the value can be + * @param max The maximum that the value can be + * @return 0 == valid + *

2 == invalid + *

1 == number too high + *

-1 == number too low + */ + public byte isValid(T min, T max) { return this.isValid(this.value, min, max); } + /** + * Checks if a new value is valid + * + * @param value Value that is being checked whether valid + * @param min The minimum that the value can be + * @param max The maximum that the value can be + * @return 0 == valid + *

2 == invalid + *

1 == number too high + *

-1 == number too low + */ + public byte isValid(T value, T min, T max) { if (this.configBase.disableMinMax) return 0; From 8727cd09af82cfeedea963c3557edb3482e9ea68 Mon Sep 17 00:00:00 2001 From: coolGi Date: Sun, 16 Jul 2023 23:40:35 +0930 Subject: [PATCH 2/5] Allowd option for values to go out of range --- .../distanthorizons/core/config/Config.java | 12 ++++++++++-- .../core/config/ConfigBase.java | 2 +- .../UnsafeValuesConfigListener.java | 19 +++++++++++++++++++ .../core/config/file/ConfigFileHandling.java | 1 + .../core/config/types/ConfigEntry.java | 10 +++++----- 5 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 core/src/main/java/com/seibel/distanthorizons/core/config/eventHandlers/UnsafeValuesConfigListener.java diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java b/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java index d76f23d19..05f70c537 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/Config.java @@ -27,6 +27,7 @@ import com.seibel.distanthorizons.api.enums.config.quickOptions.EThreadPreset; import com.seibel.distanthorizons.api.enums.worldGeneration.EDhApiDistantGeneratorMode; import com.seibel.distanthorizons.core.config.eventHandlers.QuickRenderToggleConfigEventHandler; import com.seibel.distanthorizons.core.config.eventHandlers.RenderCacheConfigEventHandler; +import com.seibel.distanthorizons.core.config.eventHandlers.UnsafeValuesConfigListener; import com.seibel.distanthorizons.core.config.eventHandlers.presets.ThreadPresetConfigEventHandler; import com.seibel.distanthorizons.core.config.eventHandlers.presets.RenderQualityPresetConfigEventHandler; import com.seibel.distanthorizons.core.config.types.ConfigCategory; @@ -1011,10 +1012,17 @@ public class Config + " Additionally, only stuff that's loaded after you enable this \n" + " will render their debug wireframes.") .build(); - + + // Note: This will reset on game restart, and should have a warning on the tooltip + public static ConfigEntry allowUnsafeValues = new ConfigEntry.Builder() + .set(false) + .setAppearance(EConfigEntryAppearance.ONLY_IN_GUI) + .addListener(UnsafeValuesConfigListener.INSTANCE) + .build(); + // can be set to public inorder to show in the config file and UI - private static ConfigCategory exampleConfigScreen = new ConfigCategory.Builder() + public static ConfigCategory exampleConfigScreen = new ConfigCategory.Builder() .set(ExampleConfigScreen.class) .build(); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/ConfigBase.java b/core/src/main/java/com/seibel/distanthorizons/core/config/ConfigBase.java index 580f92143..7b0ddd4e3 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/ConfigBase.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/ConfigBase.java @@ -68,7 +68,7 @@ public class ConfigBase }}; /** Disables the minimum and maximum of any variable */ - public boolean disableMinMax = false; // Very fun to use + public boolean disableMinMax = false; // Very fun to use, but should always be disabled by default public final List> entries = new ArrayList<>(); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/eventHandlers/UnsafeValuesConfigListener.java b/core/src/main/java/com/seibel/distanthorizons/core/config/eventHandlers/UnsafeValuesConfigListener.java new file mode 100644 index 000000000..4c0eca3bc --- /dev/null +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/eventHandlers/UnsafeValuesConfigListener.java @@ -0,0 +1,19 @@ +package com.seibel.distanthorizons.core.config.eventHandlers; + +import com.seibel.distanthorizons.core.config.Config; +import com.seibel.distanthorizons.core.config.listeners.IConfigListener; + +public class UnsafeValuesConfigListener implements IConfigListener { + public static UnsafeValuesConfigListener INSTANCE = new UnsafeValuesConfigListener(); + + @Override + public void onConfigValueSet() { + Config.Client.Advanced.Debugging.allowUnsafeValues.configBase.disableMinMax = + Config.Client.Advanced.Debugging.allowUnsafeValues.get(); + } + + @Override + public void onUiModify() { + + } +} diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/file/ConfigFileHandling.java b/core/src/main/java/com/seibel/distanthorizons/core/config/file/ConfigFileHandling.java index 0cb1aaa2a..270ecda4c 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/file/ConfigFileHandling.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/file/ConfigFileHandling.java @@ -147,6 +147,7 @@ public class ConfigFileHandling { if (entry.getType() == workConfig.get(entry.getNameWCategory()).getClass()) { // If the types are the same entry.setWithoutSaving((T) workConfig.get(entry.getNameWCategory())); entry.clampWithinRange(); + return; } LOGGER.warn("Entry ["+ entry.getNameWCategory() +"] is invalid. Expected " + entry.getType() + " but got " + workConfig.get(entry.getNameWCategory()).getClass() + ". Using default value."); diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigEntry.java b/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigEntry.java index 56f2953cb..76112607b 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigEntry.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigEntry.java @@ -107,7 +107,7 @@ public class ConfigEntry extends AbstractConfigType> implem @SuppressWarnings("unchecked") // Suppress due to its always safe public void setMin(T newMin) { if (newMin == null) - newMin = (T) NumberUtil.getMinimum(newMin.getClass()); + newMin = (T) NumberUtil.getMinimum(this.value.getClass()); this.min = newMin; } /** Gets the max value */ @@ -118,7 +118,7 @@ public class ConfigEntry extends AbstractConfigType> implem @SuppressWarnings("unchecked") // Suppress due to its always safe public void setMax(T newMax) { if (newMax == null) - newMax = (T) NumberUtil.getMinimum(newMax.getClass()); + newMax = (T) NumberUtil.getMinimum(this.value.getClass()); this.max = newMax; } /** Sets the min and max within a single setter */ @@ -143,8 +143,8 @@ public class ConfigEntry extends AbstractConfigType> implem @SuppressWarnings("unchecked") // Suppress due to its always safe public void clampWithinRange(T min, T max) { byte validness = this.isValid(min, max); - if (validness == -1) this.value = (T) NumberUtil.getMinimum(min.getClass()); - if (validness == 1) this.value = (T) NumberUtil.getMinimum(max.getClass()); + if (validness == -1) this.value = (T) NumberUtil.getMinimum(this.value.getClass()); + if (validness == 1) this.value = (T) NumberUtil.getMaximum(this.value.getClass()); } @Override @@ -221,7 +221,7 @@ public class ConfigEntry extends AbstractConfigType> implem if (Number.class.isAssignableFrom(value.getClass())) { // Only check min max if it is a number if (this.max != null && Float.parseFloat(value.toString()) > Float.parseFloat(max.toString())) return 1; - if (this.min != null && Float.parseFloat(value.toString()) < Float.parseFloat(min.toString())) + if (min != null && Float.parseFloat(value.toString()) < Float.parseFloat(min.toString())) return -1; return 0; From 76b464d5d76381e8c9ac771341566010872c691e Mon Sep 17 00:00:00 2001 From: James Seibel Date: Sun, 16 Jul 2023 09:25:44 -0500 Subject: [PATCH 3/5] Revert LOD hole bandaid fix due to performance issues reverts main change in 4a069b42d8eb0d99debe3c5a832d2bc3c8715e62 --- .../core/file/fullDatafile/FullDataFileHandler.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataFileHandler.java b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataFileHandler.java index 8b9717c8f..66d5fcd4c 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataFileHandler.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/file/fullDatafile/FullDataFileHandler.java @@ -373,12 +373,12 @@ public class FullDataFileHandler implements IFullDataSourceProvider private void writeChunkDataToMetaFile(DhSectionPos sectionPos, ChunkSizedFullDataAccessor chunkData) { FullDataMetaFile metaFile = this.fileBySectionPos.get(sectionPos); - if (metaFile == null && sectionPos.sectionDetailLevel <= this.topDetailLevel.get()) - { - // create a new file if one doesn't exist, - // this is done so we don't end up with holes where LODs should have been generated - metaFile = this.getLoadOrMakeFile(sectionPos, true); - } +// if (metaFile == null && sectionPos.sectionDetailLevel <= this.topDetailLevel.get()) +// { +// // create a new file if one doesn't exist, +// // this is done so we don't end up with holes where LODs should have been generated +// metaFile = this.getLoadOrMakeFile(sectionPos, true); +// } if (metaFile != null) { // there is a file for this position From ce3a06e4102fda2806e36b40297e2c951db6641e Mon Sep 17 00:00:00 2001 From: coolGi Date: Sun, 16 Jul 2023 23:57:27 +0930 Subject: [PATCH 4/5] fix to commit c5041de5 --- .../core/config/ConfigBase.java | 7 +--- .../core/config/NumberUtil.java | 32 ++++++++++++++++++- .../core/config/types/ConfigEntry.java | 21 ++++-------- 3 files changed, 38 insertions(+), 22 deletions(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/ConfigBase.java b/core/src/main/java/com/seibel/distanthorizons/core/config/ConfigBase.java index 7b0ddd4e3..9d8e601a9 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/ConfigBase.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/ConfigBase.java @@ -52,12 +52,7 @@ public class ConfigBase */ public static final List> acceptableInputs = new ArrayList>() {{ add(Boolean.class); - add(Byte.class); - add(Integer.class); - add(Double.class); - add(Short.class); - add(Long.class); - add(Float.class); + add(Number.class); // Contains: Byte, Short, Int, Long, Double, Float0 add(String.class); // TODO[CONFIG]: Check the type of these is valid diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/NumberUtil.java b/core/src/main/java/com/seibel/distanthorizons/core/config/NumberUtil.java index 9d63ce909..1731da4d0 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/NumberUtil.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/NumberUtil.java @@ -4,7 +4,7 @@ import java.util.HashMap; import java.util.Map; /** - * Gets the minimum or maximum values of a given type + * Helps with working with numbers that the value of which is unknown * * @author coolGi * @version 2023-7-16 @@ -35,4 +35,34 @@ public class NumberUtil { public static Number getMaximum(Class c) { return maxValues.get(c); } + + /** Does a greater than (>) operator on any number */ + public static boolean greaterThan(Number a, Number b) { + if (a.getClass() != b.getClass()) + return false; + Class typeClass = a.getClass(); + + if (typeClass == Byte.class) return a.byteValue() > b.byteValue(); + if (typeClass == Short.class) return a.shortValue() > b.shortValue(); + if (typeClass == Integer.class) return a.intValue() > b.intValue(); + if (typeClass == Long.class) return a.longValue() > b.longValue(); + if (typeClass == Double.class) return a.doubleValue() > b.doubleValue(); + if (typeClass == Float.class) return a.floatValue() > b.floatValue(); + return false; + } + + /** Does a less than (<) operator on any number */ + public static boolean lessThan(Number a, Number b) { + if (a.getClass() != b.getClass()) + return false; + Class typeClass = a.getClass(); + + if (typeClass == Byte.class) return a.byteValue() < b.byteValue(); + if (typeClass == Short.class) return a.shortValue() < b.shortValue(); + if (typeClass == Integer.class) return a.intValue() < b.intValue(); + if (typeClass == Long.class) return a.longValue() < b.longValue(); + if (typeClass == Double.class) return a.doubleValue() < b.doubleValue(); + if (typeClass == Float.class) return a.floatValue() < b.floatValue(); + return false; + } } diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigEntry.java b/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigEntry.java index 76112607b..a297bdb3e 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigEntry.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigEntry.java @@ -42,7 +42,8 @@ public class ConfigEntry extends AbstractConfigType> implem super(appearance, value); this.defaultValue = value; this.comment = comment; - this.setMinMax(min, max); + this.min = min; + this.max = max; this.allowApiOverride = allowApiOverride; this.performance = performance; this.listenerList = listenerList; @@ -104,23 +105,13 @@ public class ConfigEntry extends AbstractConfigType> implem public T getMin() { return this.min; } /** Sets the min value */ @Override - @SuppressWarnings("unchecked") // Suppress due to its always safe - public void setMin(T newMin) { - if (newMin == null) - newMin = (T) NumberUtil.getMinimum(this.value.getClass()); - this.min = newMin; - } + public void setMin(T newMin) { this.min = newMin; } /** Gets the max value */ @Override public T getMax() { return this.max; } /** Sets the max value */ @Override - @SuppressWarnings("unchecked") // Suppress due to its always safe - public void setMax(T newMax) { - if (newMax == null) - newMax = (T) NumberUtil.getMinimum(this.value.getClass()); - this.max = newMax; - } + public void setMax(T newMax) { this.max = newMax; } /** Sets the min and max within a single setter */ @Override public void setMinMax(T newMin, T newMax) { @@ -219,9 +210,9 @@ public class ConfigEntry extends AbstractConfigType> implem if (value.getClass() != this.value.getClass()) // If the 2 variables aren't the same type then it will be invalid return 2; if (Number.class.isAssignableFrom(value.getClass())) { // Only check min max if it is a number - if (this.max != null && Float.parseFloat(value.toString()) > Float.parseFloat(max.toString())) + if (max != null && NumberUtil.greaterThan((Number) value, (Number) max)) return 1; - if (min != null && Float.parseFloat(value.toString()) < Float.parseFloat(min.toString())) + if (min != null && NumberUtil.lessThan((Number) value, (Number) min)) return -1; return 0; From 66f4595b7b22b25a30046e96c7befb7edeae83aa Mon Sep 17 00:00:00 2001 From: coolGi Date: Mon, 17 Jul 2023 00:27:32 +0930 Subject: [PATCH 5/5] Fixed values being able to go over number limit --- .../com/seibel/distanthorizons/core/config/ConfigBase.java | 7 ++++++- .../distanthorizons/core/config/types/ConfigEntry.java | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/ConfigBase.java b/core/src/main/java/com/seibel/distanthorizons/core/config/ConfigBase.java index 9d8e601a9..7b0ddd4e3 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/ConfigBase.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/ConfigBase.java @@ -52,7 +52,12 @@ public class ConfigBase */ public static final List> acceptableInputs = new ArrayList>() {{ add(Boolean.class); - add(Number.class); // Contains: Byte, Short, Int, Long, Double, Float0 + add(Byte.class); + add(Integer.class); + add(Double.class); + add(Short.class); + add(Long.class); + add(Float.class); add(String.class); // TODO[CONFIG]: Check the type of these is valid diff --git a/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigEntry.java b/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigEntry.java index a297bdb3e..6cc64d209 100644 --- a/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigEntry.java +++ b/core/src/main/java/com/seibel/distanthorizons/core/config/types/ConfigEntry.java @@ -207,7 +207,7 @@ public class ConfigEntry extends AbstractConfigType> implem if (this.configBase.disableMinMax) return 0; - if (value.getClass() != this.value.getClass()) // If the 2 variables aren't the same type then it will be invalid + if (value == null || this.value == null || value.getClass() != this.value.getClass()) // If the 2 variables aren't the same type then it will be invalid return 2; if (Number.class.isAssignableFrom(value.getClass())) { // Only check min max if it is a number if (max != null && NumberUtil.greaterThan((Number) value, (Number) max))