Launcher/LauncherAPI/src/main/java/pro/gravit/launcher/config/SimpleConfigurable.java

33 lines
690 B
Java
Raw Normal View History

package pro.gravit.launcher.config;
import java.nio.file.Path;
public class SimpleConfigurable<T> extends JsonConfigurable<T> {
public T config;
private final Class<T> tClass;
public SimpleConfigurable(Class<T> type, Path configPath) {
super(type, configPath);
tClass = type;
}
@Override
public T getConfig() {
return config;
}
@Override
public T getDefaultConfig() {
try {
return tClass.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
return null;
}
}
@Override
public void setConfig(T config) {
this.config = config;
}
}