From 8127c30fc791826c3d3f95d9e3ac21ebb3a0a6bf Mon Sep 17 00:00:00 2001 From: zaaarf Date: Thu, 2 Mar 2023 10:43:58 +0100 Subject: chore: checkerframework --- src/main/java/ftbsc/bscv/Boscovicino.java | 2 ++ src/main/java/ftbsc/bscv/system/ModManager.java | 30 ++++++++++++------------- 2 files changed, 17 insertions(+), 15 deletions(-) (limited to 'src') 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 cfgBuilder; - private Optional> dispatcher; + private Builder cfgBuilder; + private CommandDispatcher dispatcher; public final Set mods; public final Set categories; - public ModManager(ForgeConfigSpec.Builder cfgBuilder, CommandDispatcher dispatcher) { - this.cfgBuilder = Optional.of(cfgBuilder); - this.dispatcher = Optional.of(dispatcher); + public ModManager(Builder cfgBuilder, CommandDispatcher 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 getDispatcher() { - return dispatcher.get(); + public @Nullable CommandDispatcher getDispatcher() { + return dispatcher; } } -- cgit v1.2.3-56-ga3b1