diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/config/SimpleConfig.java b/LauncherAPI/src/main/java/pro/gravit/launcher/config/SimpleConfig.java new file mode 100644 index 00000000..764cab2b --- /dev/null +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/config/SimpleConfig.java @@ -0,0 +1,39 @@ +package pro.gravit.launcher.config; + +import java.lang.reflect.Type; +import java.nio.file.Path; + +public abstract class SimpleConfig implements JsonConfigurableInterface { + private transient final Class type; + protected transient final Path configPath; + + protected SimpleConfig(Class type, Path configPath) { + this.type = type; + this.configPath = configPath; + } + @SuppressWarnings("unchecked") + @Override + public T getConfig() { + return (T) this; + } + + @Override + public T getDefaultConfig() { + try { + return type.newInstance(); + } catch (InstantiationException | IllegalAccessException e) { + return null; + } + } + + @Override + public Path getPath() { + return configPath; + } + + @Override + public Type getType() { + return type; + } + +}