From c0fe1688d8a377e3d51e405b53708b56cfc14c52 Mon Sep 17 00:00:00 2001 From: Thomas Kain Date: Mon, 3 Jul 2023 20:28:37 -0400 Subject: [PATCH] Make overloads consistent for defineListAllowEmpty in ForgeConfigSpec.Builder (#9604) --- mdk/src/main/java/com/example/examplemod/Config.java | 2 +- .../net/minecraftforge/common/ForgeConfigSpec.java | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) 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) {