diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/AbstractSampler.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/AbstractSampler.java index 17e0e64d..a353263f 100644 --- a/spark-common/src/main/java/me/lucko/spark/common/sampler/AbstractSampler.java +++ b/spark-common/src/main/java/me/lucko/spark/common/sampler/AbstractSampler.java @@ -174,7 +174,7 @@ protected void sendStatisticsToSocket() { viewerSocket.sendUpdatedStatistics(platform, system); } } catch (Exception e) { - platform.getPlugin().log(Level.WARNING, "Exception occurred while sending statistics to viewer", e); + this.platform.getPlugin().log(Level.WARNING, "Exception occurred while sending statistics to viewer", e); } } diff --git a/spark-fabric/build.gradle b/spark-fabric/build.gradle index d2905cd5..24b9766a 100644 --- a/spark-fabric/build.gradle +++ b/spark-fabric/build.gradle @@ -43,7 +43,7 @@ dependencies { modImplementation(fabricApi.module(it, '0.106.1+1.21.3')) } - include(modImplementation('me.lucko:fabric-permissions-api:0.3.2')) + include(modImplementation('me.lucko:fabric-permissions-api:0.3.3')) modImplementation('eu.pb4:placeholder-api:2.5.0+1.21.2') diff --git a/spark-fabric/src/main/java/me/lucko/spark/fabric/FabricSparkMod.java b/spark-fabric/src/main/java/me/lucko/spark/fabric/FabricSparkMod.java index 23a518b2..8772786e 100644 --- a/spark-fabric/src/main/java/me/lucko/spark/fabric/FabricSparkMod.java +++ b/spark-fabric/src/main/java/me/lucko/spark/fabric/FabricSparkMod.java @@ -60,7 +60,7 @@ public void onInitialize() { CommandRegistrationCallback.EVENT.register(this::onServerCommandRegister); } - // client (called be entrypoint defined in fabric.mod.json) + // client (called by entrypoint defined in fabric.mod.json) public static void initializeClient() { Objects.requireNonNull(FabricSparkMod.mod, "mod"); FabricClientSparkPlugin.register(FabricSparkMod.mod, MinecraftClient.getInstance()); diff --git a/spark-forge/src/main/java/me/lucko/spark/forge/ForgeSparkMod.java b/spark-forge/src/main/java/me/lucko/spark/forge/ForgeSparkMod.java index 1a7b8e17..07dce65b 100644 --- a/spark-forge/src/main/java/me/lucko/spark/forge/ForgeSparkMod.java +++ b/spark-forge/src/main/java/me/lucko/spark/forge/ForgeSparkMod.java @@ -27,10 +27,8 @@ import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.IExtensionPoint; import net.minecraftforge.fml.ModContainer; -import net.minecraftforge.fml.ModLoadingContext; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; -import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import net.minecraftforge.fml.loading.FMLPaths; @@ -39,26 +37,23 @@ @Mod("spark") public class ForgeSparkMod { - private ModContainer container; - private Path configDirectory; + private final ModContainer container; + private final Path configDirectory; - public ForgeSparkMod() { - FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); - FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientInit); - MinecraftForge.EVENT_BUS.register(this); + public ForgeSparkMod(FMLJavaModLoadingContext ctx) { + this.container = ctx.getContainer(); + this.configDirectory = FMLPaths.CONFIGDIR.get().resolve(this.container.getModId()); - ModLoadingContext.get().registerDisplayTest(IExtensionPoint.DisplayTest.IGNORE_ALL_VERSION); + ctx.getModEventBus().addListener(this::clientInit); + ctx.registerDisplayTest(IExtensionPoint.DisplayTest.IGNORE_ALL_VERSION); + + MinecraftForge.EVENT_BUS.register(this); } public String getVersion() { return this.container.getModInfo().getVersion().toString(); } - public void setup(FMLCommonSetupEvent e) { - this.container = ModLoadingContext.get().getActiveContainer(); - this.configDirectory = FMLPaths.CONFIGDIR.get().resolve(this.container.getModId()); - } - public void clientInit(FMLClientSetupEvent e) { ForgeClientSparkPlugin.register(this, e); } @@ -69,9 +64,6 @@ public void serverInit(ServerAboutToStartEvent e) { } public Path getConfigDirectory() { - if (this.configDirectory == null) { - throw new IllegalStateException("Config directory not set"); - } return this.configDirectory; } } diff --git a/spark-neoforge/src/main/java/me/lucko/spark/neoforge/NeoForgeSparkMod.java b/spark-neoforge/src/main/java/me/lucko/spark/neoforge/NeoForgeSparkMod.java index 72436c9d..706deb16 100644 --- a/spark-neoforge/src/main/java/me/lucko/spark/neoforge/NeoForgeSparkMod.java +++ b/spark-neoforge/src/main/java/me/lucko/spark/neoforge/NeoForgeSparkMod.java @@ -25,10 +25,8 @@ import net.neoforged.bus.api.IEventBus; import net.neoforged.bus.api.SubscribeEvent; import net.neoforged.fml.ModContainer; -import net.neoforged.fml.ModLoadingContext; import net.neoforged.fml.common.Mod; import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent; -import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent; import net.neoforged.fml.loading.FMLPaths; import net.neoforged.neoforge.common.NeoForge; import net.neoforged.neoforge.event.server.ServerAboutToStartEvent; @@ -38,15 +36,15 @@ @Mod("spark") public class NeoForgeSparkMod { - private ModContainer container; - private Path configDirectory; + private final ModContainer container; + private final Path configDirectory; - private IEventBus eventBus; + public NeoForgeSparkMod(ModContainer container, IEventBus eventBus) { + this.container = container; + this.configDirectory = FMLPaths.CONFIGDIR.get().resolve(this.container.getModId()); - public NeoForgeSparkMod(IEventBus eventBus) { - this.eventBus = eventBus; - eventBus.addListener(this::setup); eventBus.addListener(this::clientInit); + NeoForge.EVENT_BUS.register(this); } @@ -54,11 +52,6 @@ public String getVersion() { return this.container.getModInfo().getVersion().toString(); } - public void setup(FMLCommonSetupEvent e) { - this.container = ModLoadingContext.get().getActiveContainer(); - this.configDirectory = FMLPaths.CONFIGDIR.get().resolve(this.container.getModId()); - } - public void clientInit(FMLClientSetupEvent e) { NeoForgeClientSparkPlugin.register(this, e); } @@ -69,9 +62,6 @@ public void serverInit(ServerAboutToStartEvent e) { } public Path getConfigDirectory() { - if (this.configDirectory == null) { - throw new IllegalStateException("Config directory not set"); - } return this.configDirectory; } }