Skip to content

Commit

Permalink
Build fixing intensifies
Browse files Browse the repository at this point in the history
Also fixes a bug in Configs where the default template was marked as nullable but would crash if null
  • Loading branch information
Chocohead committed Apr 26, 2021
1 parent d6361f7 commit 7a44b37
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

2 comments on commit 7a44b37

@valoeghese
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait choco did you update an api without bumping the submodule version :irritated:

@Chocohead
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You couldn't have passed in null previously... but I suppose yes I did overlook the fact the main API version had increased but not the submodule

Please sign in to comment.