Attempt to fix config changes
This commit is contained in:
parent
3fb16789b9
commit
cae18bfa00
|
@ -9,6 +9,6 @@ import java.lang.annotation.Target;
|
|||
@Target(ElementType.FIELD)
|
||||
public @interface Entry {
|
||||
int width() default 100;
|
||||
double min() default Double.MIN_NORMAL;
|
||||
double max() default Double.MAX_VALUE;
|
||||
double min() default Double.NEGATIVE_INFINITY;
|
||||
double max() default Double.POSITIVE_INFINITY;
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import io.gitlab.jfronny.libjf.config.api.Entry;
|
|||
import io.gitlab.jfronny.libjf.config.api.Preset;
|
||||
import io.gitlab.jfronny.libjf.config.api.Verifier;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
@ -13,7 +12,6 @@ import java.lang.reflect.Method;
|
|||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/** Based on https://github.com/TeamMidnightDust/MidnightLib which is based on https://github.com/Minenash/TinyConfig
|
||||
* Credits to TeamMidnightDust and Minenash */
|
||||
|
@ -102,11 +100,12 @@ public class Config {
|
|||
});
|
||||
try {
|
||||
LibJf.GSON.fromJson(Files.newBufferedReader(path), config);
|
||||
syncFromClass();
|
||||
}
|
||||
catch (Exception e) {
|
||||
write();
|
||||
LibJf.LOGGER.error("Could not read config", e);
|
||||
}
|
||||
syncFromClass();
|
||||
write();
|
||||
}
|
||||
|
||||
public void syncToClass() {
|
||||
|
@ -127,6 +126,7 @@ public class Config {
|
|||
for (EntryInfo info : entries) {
|
||||
try {
|
||||
info.value = info.field.get(null);
|
||||
info.tempValue = info.value.toString();
|
||||
} catch (IllegalAccessException e) {
|
||||
LibJf.LOGGER.error("Could not read value", e);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue