diff options
author | Anthony Hilyard <anthony.hilyard@gmail.com> | 2022-01-31 17:58:26 -0800 |
---|---|---|
committer | Anthony Hilyard <anthony.hilyard@gmail.com> | 2022-01-31 17:58:26 -0800 |
commit | 312cf6b1d2990d7632807dfa5ef93b8dd2cbb865 (patch) | |
tree | ae0bf2bb458745766bcacdb4be460d7da1357f3f | |
parent | efe2214f497848e747192b7964af68bb7c94fd33 (diff) | |
download | Iceberg-312cf6b1d2990d7632807dfa5ef93b8dd2cbb865.tar.gz Iceberg-312cf6b1d2990d7632807dfa5ef93b8dd2cbb865.tar.bz2 Iceberg-312cf6b1d2990d7632807dfa5ef93b8dd2cbb865.zip |
Fixed config registration bug.
-rw-r--r-- | CHANGELOG.md | 3 | ||||
-rw-r--r-- | gradle.properties | 2 | ||||
-rw-r--r-- | src/main/java/com/anthonyhilyard/iceberg/config/IcebergConfig.java | 19 |
3 files changed, 19 insertions, 5 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 937c5e8..b60fca5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +### 1.0.40 +- Fixed a bug in configuration system that caused mod configs to sometimes fail to register properly. + ### 1.0.39 - Added new config system that improves upon Forge's with subconfig support, improved reload reliability, and reduced boilerplate. diff --git a/gradle.properties b/gradle.properties index 3e4c4b9..6f85d13 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,6 +6,6 @@ org.gradle.daemon=false name=${rootProject.name} group=com.anthonyhilyard.${name.toLowerCase()} author=anthonyhilyard -version=1.0.39 +version=1.0.40 mcVersion=1.18.1 forgeVersion=39.0.9 diff --git a/src/main/java/com/anthonyhilyard/iceberg/config/IcebergConfig.java b/src/main/java/com/anthonyhilyard/iceberg/config/IcebergConfig.java index cc48c2c..0ce0670 100644 --- a/src/main/java/com/anthonyhilyard/iceberg/config/IcebergConfig.java +++ b/src/main/java/com/anthonyhilyard/iceberg/config/IcebergConfig.java @@ -1,9 +1,12 @@ package com.anthonyhilyard.iceberg.config; +import java.util.Set; + import javax.annotation.Nonnull; import com.anthonyhilyard.iceberg.Loader; import com.electronwill.nightconfig.core.Config; +import com.google.common.collect.Sets; import org.apache.commons.lang3.tuple.Pair; @@ -18,7 +21,7 @@ public abstract class IcebergConfig<T extends IcebergConfig<?>> private static IcebergConfigSpec SPEC = null; private static IcebergConfig<?> INSTANCE = null; private static String modId = null; - private static boolean registered = false; + private static Set<Class<?>> registeredClasses = Sets.newHashSet(); protected abstract <I extends IcebergConfig<?>> void setInstance(I instance); protected void onLoad() {} @@ -49,8 +52,9 @@ public abstract class IcebergConfig<T extends IcebergConfig<?>> public static final boolean register(Class<? extends IcebergConfig<?>> superClass, @Nonnull String modId) { - if (registered) + if (registeredClasses.contains(superClass)) { + Loader.LOGGER.warn("Failed to register configuration: {} is already registered!", superClass.getName()); return false; } @@ -72,8 +76,15 @@ public abstract class IcebergConfig<T extends IcebergConfig<?>> return result; }); - if (specPair.getRight() == null || specPair.getLeft() == null) + if (specPair.getRight() == null) + { + Loader.LOGGER.warn("Failed to register configuration: Generated spec was null!"); + return false; + } + + if (specPair.getLeft() == null) { + Loader.LOGGER.warn("Failed to register configuration: Generated configuration instance was null!"); return false; } @@ -83,7 +94,7 @@ public abstract class IcebergConfig<T extends IcebergConfig<?>> ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, SPEC); - registered = true; + registeredClasses.add(superClass); return true; } } |