diff --git a/src/main/java/vazkii/quark/base/module/config/IConfigBuilder.java b/src/main/java/vazkii/quark/base/module/config/IConfigBuilder.java index 349f3f42cb..ea40e3b5dc 100644 --- a/src/main/java/vazkii/quark/base/module/config/IConfigBuilder.java +++ b/src/main/java/vazkii/quark/base/module/config/IConfigBuilder.java @@ -14,10 +14,11 @@ public interface IConfigBuilder { void pop(); void comment(String s); - ForgeConfigSpec.ConfigValue> defineList(String name, List default_, Supplier> getter, Predicate predicate); - ForgeConfigSpec.ConfigValue defineObj(String name, Object default_, Supplier getter, Predicate predicate); + ForgeConfigSpec.ConfigValue> defineList(String name, List default_, Supplier> getter, Predicate predicate); + ForgeConfigSpec.ConfigValue defineObj(String name, T default_, Supplier getter, Predicate predicate); + + default ForgeConfigSpec.ConfigValue defineBool(String name, Supplier getter, boolean default_) { + return defineObj(name, default_, getter, x -> true); + } - ForgeConfigSpec.ConfigValue defineBool(String name, Supplier getter, boolean default_); - ForgeConfigSpec.ConfigValue defineInt(String name, Supplier getter, int default_); - ForgeConfigSpec.ConfigValue defineDouble(String name, Supplier getter, double default_); } diff --git a/src/main/java/vazkii/quark/base/module/config/QuarkConfigBuilder.java b/src/main/java/vazkii/quark/base/module/config/QuarkConfigBuilder.java index db8a4d2897..e910db9d4a 100644 --- a/src/main/java/vazkii/quark/base/module/config/QuarkConfigBuilder.java +++ b/src/main/java/vazkii/quark/base/module/config/QuarkConfigBuilder.java @@ -48,20 +48,20 @@ public void comment(String s) { } @Override - public ConfigValue> defineList(String name, List default_, Supplier> getter, Predicate predicate) { + public ConfigValue> defineList(String name, List default_, Supplier> getter, Predicate predicate) { beforeDefine(); - ConfigValue> value = parent.defineList(name, default_, predicate); + ConfigValue> value = parent.defineList(name, default_, predicate); onDefine(value, default_, getter, predicate); return value; } @Override - public ConfigValue defineObj(String name, Object default_, Supplier getter, Predicate predicate) { + public ConfigValue defineObj(String name, T default_, Supplier getter, Predicate predicate) { if(default_ == null) throw new RuntimeException("Can't define object " + name + " with null default @ " + layers.toString()); beforeDefine(); - ConfigValue value = parent.define(name, default_, predicate); + ConfigValue value = parent.define(name, default_, predicate); onDefine(value, default_, getter, predicate); return value; } @@ -74,24 +74,8 @@ public ConfigValue defineBool(String name, Supplier getter, bo return value; } - @Override - public ConfigValue defineInt(String name, Supplier getter, int default_) { - beforeDefine(); - ConfigValue value = parent.define(name, default_); - onDefine(value, default_, getter, o -> true); - return value; - } - - @Override - public ConfigValue defineDouble(String name, Supplier getter, double default_) { - beforeDefine(); - ConfigValue value = parent.define(name, default_); - onDefine(value, default_, getter, o -> true); - return value; - } - private void beforeDefine() { - if(currComment.length() > 0) + if(!currComment.isEmpty()) parent.comment(currComment); }