diff --git a/common/src/main/java/com/dfsek/terra/config/loaders/mod/ModDependentConfigSection.java b/common/src/main/java/com/dfsek/terra/config/loaders/mod/ModDependentConfigSection.java index d1a76a5a4..40d06d74b 100644 --- a/common/src/main/java/com/dfsek/terra/config/loaders/mod/ModDependentConfigSection.java +++ b/common/src/main/java/com/dfsek/terra/config/loaders/mod/ModDependentConfigSection.java @@ -13,7 +13,7 @@ public class ModDependentConfigSection { private final Map results = new HashMap<>(); private final T defaultValue; - public ModDependentConfigSection(TerraPlugin main, T defaultValue) { + protected ModDependentConfigSection(TerraPlugin main, T defaultValue) { this.main = main; this.defaultValue = defaultValue; } @@ -22,10 +22,16 @@ public class ModDependentConfigSection { results.put(id, value); } + public static ModDependentConfigSection withDefault(T1 defaultValue) { + return new ModDependentConfigSection<>(null, defaultValue); + } + public T get() { - Set mods = main.getMods().stream().map(Mod::getID).collect(Collectors.toSet()); - for(Map.Entry entry : results.entrySet()) { - if(mods.contains(entry.getKey())) return entry.getValue(); + if(main != null) { + Set mods = main.getMods().stream().map(Mod::getID).collect(Collectors.toSet()); + for(Map.Entry entry : results.entrySet()) { + if(mods.contains(entry.getKey())) return entry.getValue(); + } } return defaultValue; }