diff --git a/mdk/src/main/java/com/example/examplemod/Config.java b/mdk/src/main/java/com/example/examplemod/Config.java index 0ac7934a41..46013453c1 100644 --- a/mdk/src/main/java/com/example/examplemod/Config.java +++ b/mdk/src/main/java/com/example/examplemod/Config.java @@ -35,7 +35,7 @@ public class Config // a list of strings that are treated as resource locations for items private static final ForgeConfigSpec.ConfigValue> ITEM_STRINGS = BUILDER .comment("A list of items to log on common setup.") - .defineListAllowEmpty(Collections.singletonList("items"), () -> List.of("minecraft:iron_ingot"), Config::validateItemName); + .defineListAllowEmpty("items", List.of("minecraft:iron_ingot"), Config::validateItemName); static final ForgeConfigSpec SPEC = BUILDER.build(); diff --git a/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java b/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java index 34804da710..6484558248 100644 --- a/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java +++ b/src/main/java/net/minecraftforge/common/ForgeConfigSpec.java @@ -380,7 +380,15 @@ public class ForgeConfigSpec extends UnmodifiableConfigWrapper ConfigValue> defineListAllowEmpty(String path, List defaultValue, Predicate elementValidator) { + return defineListAllowEmpty(split(path), defaultValue, elementValidator); + } + public ConfigValue> defineListAllowEmpty(String path, Supplier> defaultSupplier, Predicate elementValidator) { + return defineListAllowEmpty(split(path), defaultSupplier, elementValidator); + } + public ConfigValue> defineListAllowEmpty(List path, List defaultValue, Predicate elementValidator) { + return defineListAllowEmpty(path, () -> defaultValue, elementValidator); + } public ConfigValue> defineListAllowEmpty(List path, Supplier> defaultSupplier, Predicate elementValidator) { context.setClazz(List.class); return define(path, new ValueSpec(defaultSupplier, x -> x instanceof List && ((List) x).stream().allMatch( elementValidator ), context, path) {