diff options
author | zaaarf <zaaarf@proton.me> | 2023-03-02 10:43:58 +0100 |
---|---|---|
committer | zaaarf <zaaarf@proton.me> | 2023-03-02 10:45:46 +0100 |
commit | 8127c30fc791826c3d3f95d9e3ac21ebb3a0a6bf (patch) | |
tree | 3a492b392af0c4ff98d5987da514dc6a2e40f5cc /src/main/java | |
parent | eb5ee8e45313c6856b52e5f53b8aa73d7506246b (diff) |
chore: checkerframework
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/ftbsc/bscv/Boscovicino.java | 2 | ||||
-rw-r--r-- | src/main/java/ftbsc/bscv/system/ModManager.java | 30 |
2 files changed, 17 insertions, 15 deletions
diff --git a/src/main/java/ftbsc/bscv/Boscovicino.java b/src/main/java/ftbsc/bscv/Boscovicino.java index 4754182..d54a3d4 100644 --- a/src/main/java/ftbsc/bscv/Boscovicino.java +++ b/src/main/java/ftbsc/bscv/Boscovicino.java @@ -52,6 +52,8 @@ public class Boscovicino implements ICommons { Boscovicino.modManager = new ModManager(cfg, dp); Boscovicino.modManager.load(); + Boscovicino.modManager.finish(); + Boscovicino.spec = cfg.build(); ForgeConfigSpec.Builder friendSpec = new ForgeConfigSpec.Builder(); diff --git a/src/main/java/ftbsc/bscv/system/ModManager.java b/src/main/java/ftbsc/bscv/system/ModManager.java index e5f1c3c..2668a79 100644 --- a/src/main/java/ftbsc/bscv/system/ModManager.java +++ b/src/main/java/ftbsc/bscv/system/ModManager.java @@ -4,23 +4,23 @@ import com.mojang.brigadier.CommandDispatcher; import ftbsc.bscv.api.ILoadable; import ftbsc.bscv.api.IModule; import net.minecraft.command.CommandSource; -import net.minecraftforge.common.ForgeConfigSpec; +import net.minecraftforge.common.ForgeConfigSpec.Builder; +import org.checkerframework.checker.nullness.qual.Nullable; import java.util.HashSet; -import java.util.Optional; import java.util.ServiceLoader; import java.util.Set; public class ModManager { - private Optional<ForgeConfigSpec.Builder> cfgBuilder; - private Optional<CommandDispatcher<CommandSource>> dispatcher; + private Builder cfgBuilder; + private CommandDispatcher<CommandSource> dispatcher; public final Set<IModule> mods; public final Set<String> categories; - public ModManager(ForgeConfigSpec.Builder cfgBuilder, CommandDispatcher<CommandSource> dispatcher) { - this.cfgBuilder = Optional.of(cfgBuilder); - this.dispatcher = Optional.of(dispatcher); + public ModManager(Builder cfgBuilder, CommandDispatcher<CommandSource> dispatcher) { + this.cfgBuilder = cfgBuilder; + this.dispatcher = dispatcher; this.mods = new HashSet<>(); this.categories = new HashSet<>(); } @@ -31,21 +31,21 @@ public class ModManager { IModule mod = (IModule) module; this.mods.add(mod); this.categories.add(mod.getGroup()); - this.cfgBuilder.get().pop(); // TODO solved by AutoService, soon TM + this.cfgBuilder.pop(); // TODO } } } - public void finalize() { - this.cfgBuilder = Optional.empty(); - this.dispatcher = Optional.empty(); + public void finish() { + this.cfgBuilder = null; + this.dispatcher = null; } - public ForgeConfigSpec.Builder getCfgBuilder() { - return cfgBuilder.get(); + public @Nullable Builder getCfgBuilder() { + return cfgBuilder; } - public CommandDispatcher<CommandSource> getDispatcher() { - return dispatcher.get(); + public @Nullable CommandDispatcher<CommandSource> getDispatcher() { + return dispatcher; } } |