diff options
Diffstat (limited to 'src/main/java/dev/isxander/yacl/config')
3 files changed, 13 insertions, 10 deletions
diff --git a/src/main/java/dev/isxander/yacl/config/ConfigInstance.java b/src/main/java/dev/isxander/yacl/config/ConfigInstance.java index 8795eb1..18733f3 100644 --- a/src/main/java/dev/isxander/yacl/config/ConfigInstance.java +++ b/src/main/java/dev/isxander/yacl/config/ConfigInstance.java @@ -1,5 +1,8 @@ package dev.isxander.yacl.config; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.lang.reflect.InvocationTargetException; /** @@ -13,6 +16,8 @@ import java.lang.reflect.InvocationTargetException; * @param <T> config data type */ public abstract class ConfigInstance<T> { + protected final static Logger logger = LoggerFactory.getLogger("YetAnotherConfigLib"); + private final Class<T> configClass; private final T defaultInstance; private T instance; diff --git a/src/main/java/dev/isxander/yacl/config/GsonConfigInstance.java b/src/main/java/dev/isxander/yacl/config/GsonConfigInstance.java index 40c2c99..3e075ab 100644 --- a/src/main/java/dev/isxander/yacl/config/GsonConfigInstance.java +++ b/src/main/java/dev/isxander/yacl/config/GsonConfigInstance.java @@ -1,7 +1,6 @@ package dev.isxander.yacl.config; import com.google.gson.*; -import dev.isxander.yacl.impl.utils.YACLConstants; import net.minecraft.text.Style; import net.minecraft.text.Text; @@ -54,7 +53,7 @@ public class GsonConfigInstance<T> extends ConfigInstance<T> { @Override public void save() { try { - YACLConstants.LOGGER.info("Saving {}...", getConfigClass().getSimpleName()); + logger.info("Saving {}...", getConfigClass().getSimpleName()); Files.writeString(path, gson.toJson(getConfig()), StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE); } catch (IOException e) { e.printStackTrace(); @@ -69,7 +68,7 @@ public class GsonConfigInstance<T> extends ConfigInstance<T> { return; } - YACLConstants.LOGGER.info("Loading {}...", getConfigClass().getSimpleName()); + logger.info("Loading {}...", getConfigClass().getSimpleName()); setConfig(gson.fromJson(Files.readString(path), getConfigClass())); } catch (IOException e) { e.printStackTrace(); diff --git a/src/main/java/dev/isxander/yacl/config/NbtConfigInstance.java b/src/main/java/dev/isxander/yacl/config/NbtConfigInstance.java index 5749695..8f817cb 100644 --- a/src/main/java/dev/isxander/yacl/config/NbtConfigInstance.java +++ b/src/main/java/dev/isxander/yacl/config/NbtConfigInstance.java @@ -1,6 +1,5 @@ package dev.isxander.yacl.config; -import dev.isxander.yacl.impl.utils.YACLConstants; import net.minecraft.nbt.*; import java.awt.*; @@ -58,13 +57,13 @@ public class NbtConfigInstance<T> extends ConfigInstance<T> { @Override public void save() { - YACLConstants.LOGGER.info("Saving {}...", getConfigClass().getSimpleName()); + logger.info("Saving {}...", getConfigClass().getSimpleName()); NbtCompound nbt; try { nbt = (NbtCompound) serializeObject(getConfig(), nbtSerializerHolder, field -> field.isAnnotationPresent(ConfigEntry.class)); } catch (IllegalAccessException e) { - YACLConstants.LOGGER.error("Failed to convert '{}' -> NBT", getConfigClass().getName(), e); + logger.error("Failed to convert '{}' -> NBT", getConfigClass().getName(), e); return; } @@ -77,7 +76,7 @@ public class NbtConfigInstance<T> extends ConfigInstance<T> { else NbtIo.write(nbt, new DataOutputStream(fos)); } catch (IOException e) { - YACLConstants.LOGGER.error("Failed to write NBT to '{}'", path, e); + logger.error("Failed to write NBT to '{}'", path, e); } } @@ -88,19 +87,19 @@ public class NbtConfigInstance<T> extends ConfigInstance<T> { return; } - YACLConstants.LOGGER.info("Loading {}...", getConfigClass().getSimpleName()); + logger.info("Loading {}...", getConfigClass().getSimpleName()); NbtCompound nbt; try { nbt = compressed ? NbtIo.readCompressed(path.toFile()) : NbtIo.read(path.toFile()); } catch (IOException e) { - YACLConstants.LOGGER.error("Failed to read NBT file '{}'", path, e); + logger.error("Failed to read NBT file '{}'", path, e); return; } try { setConfig(deserializeObject(nbt, getConfigClass(), nbtSerializerHolder, field -> field.isAnnotationPresent(ConfigEntry.class))); } catch (InvocationTargetException | NoSuchMethodException | InstantiationException | IllegalAccessException e) { - YACLConstants.LOGGER.error("Failed to convert NBT -> '{}'", getConfigClass().getName(), e); + logger.error("Failed to convert NBT -> '{}'", getConfigClass().getName(), e); } } |