From 8127c30fc791826c3d3f95d9e3ac21ebb3a0a6bf Mon Sep 17 00:00:00 2001 From: zaaarf Date: Thu, 2 Mar 2023 10:43:58 +0100 Subject: [PATCH] chore: checkerframework --- build.gradle | 1 + gradle/libs.versions.toml | 4 ++- src/main/java/ftbsc/bscv/Boscovicino.java | 2 ++ .../java/ftbsc/bscv/system/ModManager.java | 30 +++++++++---------- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/build.gradle b/build.gradle index 0a783d8..170d5d8 100644 --- a/build.gradle +++ b/build.gradle @@ -3,6 +3,7 @@ plugins { id 'eclipse' alias libs.plugins.forgeGradle; alias libs.plugins.gitVersion; + alias libs.plugins.checkerFramework } version = gitVersion() diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7b6b12a..60d9958 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -7,10 +7,12 @@ autoService = "1.0.1" javaPoet = "1.13.0" lillero = "0.3.0" lilleroProcessor = "0.2.1" +checkerFramework = "0.6.24" [plugins] forgeGradle = { id = "net.minecraftforge.gradle", version.ref = "forgeGradle" } gitVersion = { id = "com.palantir.git-version", version.ref = "gitVersion" } +checkerFramework = { id = "org.checkerframework", version.ref = "checkerFramework"} [libraries] minecraftForge = { group = "net.minecraftforge", name = "forge", version.ref = "forge" } @@ -18,4 +20,4 @@ autoService = { group = "com.google.auto.service", name = "auto-service", versio autoServiceAnnotations = { group = "com.google.auto.service", name = "auto-service-annotations", version.ref = "autoService" } javaPoet = { group = "com.squareup", name = "javapoet", version.ref = "javaPoet" } lillero = { group = "ftbsc", name = "lll", version.ref = "lillero" } -lilleroProcessor = { group = "ftbsc.lll", name = "processor", version.ref = "lilleroProcessor" } +lilleroProcessor = { group = "ftbsc.lll", name = "processor", version.ref = "lilleroProcessor" } \ No newline at end of file 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; } }