From 4c192ec8f8761c3a2b51f4e637c303db9c58ba28 Mon Sep 17 00:00:00 2001 From: P3pp3rF1y Date: Tue, 12 Mar 2024 23:30:42 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fix=20maxUpgradesPerStora?= =?UTF-8?q?ge=20config=20to=20properly=20reset=20to=20default=20if=20inval?= =?UTF-8?q?id=20value=20is=20provided?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gradle.properties | 2 +- .../java/net/p3pp3rf1y/sophisticatedbackpacks/Config.java | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index 726293bd..cbb322b2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.daemon=false mod_id=sophisticatedbackpacks mod_group_id=sophisticatedbackpacks -mod_version=3.20.2 +mod_version=3.20.3 sonar_project_key=sophisticatedbackpacks:SophisticatedBackpacks github_package_url=https://maven.pkg.github.com/P3pp3rF1y/SophisticatedBackpacks diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/Config.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/Config.java index bd280980..79f19100 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/Config.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/Config.java @@ -36,6 +36,7 @@ public class Config { private static final String REGISTRY_NAME_MATCHER = "([a-z0-9_.-]+:[a-z0-9_/.-]+)"; + private static final String MAX_UPGRADES_MATCHER = "([a-z0-9_/.-]+\\|\\d+)"; private Config() { } @@ -445,13 +446,14 @@ private void loadDisallowedSet() { } public static class MaxUgradesPerStorageConfig implements IUpgradeCountLimitConfig { - private final ForgeConfigSpec.ConfigValue> maxUpgradesPerStorageList; + private final ForgeConfigSpec.ConfigValue> maxUpgradesPerStorageList; @Nullable private Map maxUpgradesPerStorage = null; protected MaxUgradesPerStorageConfig(ForgeConfigSpec.Builder builder, Map defaultUpgradesPerStorage) { - maxUpgradesPerStorageList = builder.comment("Maximum number of upgrades of type per backpack in format of \"UpgradeRegistryName[or UpgradeGroup]|MaxNumber\"").define("maxUpgradesPerStorage", convertToList(defaultUpgradesPerStorage)); + maxUpgradesPerStorageList = builder.comment("Maximum number of upgrades of type per backpack in format of \"UpgradeRegistryName[or UpgradeGroup]|MaxNumber\"") + .defineList("maxUpgradesPerStorage", convertToList(defaultUpgradesPerStorage), mapping -> ((String) mapping).matches(MAX_UPGRADES_MATCHER)); } private List convertToList(Map defaultUpgradesPerStorage) {