diff --git a/build.gradle b/build.gradle index f9320d95..d126b2b1 100644 --- a/build.gradle +++ b/build.gradle @@ -101,6 +101,9 @@ allprojects { modImplementation("com.github.minecraft-cursed-legacy:cursed-fabric-loader:${project.loader_version}") { transitive false //Avoid leaking Loader's dependencies forwards } + + //For @Nullable and @Nonnull + compileOnly 'com.google.code.findbugs:jsr305:3.0.2' } sourceSets { diff --git a/legacy-config-v0/src/main/java/io/github/minecraftcursedlegacy/api/config/Configs.java b/legacy-config-v0/src/main/java/io/github/minecraftcursedlegacy/api/config/Configs.java index 30f6adca..6163388c 100644 --- a/legacy-config-v0/src/main/java/io/github/minecraftcursedlegacy/api/config/Configs.java +++ b/legacy-config-v0/src/main/java/io/github/minecraftcursedlegacy/api/config/Configs.java @@ -26,8 +26,6 @@ import java.io.File; import java.io.IOException; -import javax.annotation.Nullable; - import io.github.minecraftcursedlegacy.api.registry.Id; import net.fabricmc.loader.api.FabricLoader; import tk.valoeghese.zoesteriaconfig.api.ZoesteriaConfig; @@ -44,18 +42,26 @@ private Configs() { /** * Retrieves or creates a new {@link WritableConfig}, based on the given id. + * * @param configId the identifier of the config. * @param defaults defaults for the config, which can be created with a builder. * @return the {@link WritableConfig} instance with the config data in this file. + * * @throws IOException if there is an error creating the config file. + * @throws NullPointerException if {@code configId} is null */ - public static WritableConfig loadOrCreate(Id configId, @Nullable ConfigTemplate defaults) throws IOException { + public static WritableConfig loadOrCreate(Id configId, ConfigTemplate defaults) throws IOException { File directory = new File(FabricLoader.getInstance().getConfigDirectory(), configId.getNamespace()); directory.mkdirs(); File configFile = new File(directory, configId.getName() + ".cfg"); boolean createNew = configFile.createNewFile(); - WritableConfig result = ZoesteriaConfig.loadConfigWithDefaults(configFile, defaults); + WritableConfig result; + if (defaults == null) { + result = ZoesteriaConfig.loadConfig(configFile); + } else { + result = ZoesteriaConfig.loadConfigWithDefaults(configFile, defaults); + } if (createNew) { result.writeToFile(configFile);