When starting the Minecraft server with the HuskSync Fabric plugin, the server fails to start and throws a NullPointerException error.
Version
Compiled from master branch, minecraft version 1.21.1
Server log
[01:00:14] [main/ERROR]: Failed to start the minecraft server
java.lang.RuntimeException: Could not execute entrypoint stage 'server' due to errors, provided by 'husksync' at 'net.william278.husksync.FabricHuskSync'!
at net.fabricmc.loader.impl.FabricLoaderImpl.lambda$invokeEntrypoints$2(FabricLoaderImpl.java:403) ~[fabric-loader-0.16.5.jar:?]
at net.fabricmc.loader.impl.util.ExceptionUtil.gatherExceptions(ExceptionUtil.java:33) ~[fabric-loader-0.16.5.jar:?]
at net.fabricmc.loader.impl.FabricLoaderImpl.invokeEntrypoints(FabricLoaderImpl.java:401) ~[fabric-loader-0.16.5.jar:?]
at net.fabricmc.loader.impl.game.minecraft.Hooks.startServer(Hooks.java:64) ~[fabric-loader-0.16.5.jar:?]
at net.minecraft.server.Main.main(Main.java:111) [server-intermediary.jar:?]
at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:480) [fabric-loader-0.16.5.jar:?]
at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74) [fabric-loader-0.16.5.jar:?]
at net.fabricmc.loader.impl.launch.knot.KnotServer.main(KnotServer.java:23) [fabric-loader-0.16.5.jar:?]
at net.fabricmc.loader.impl.launch.server.FabricServerLauncher.main(FabricServerLauncher.java:69) [fabric-loader-0.16.5.jar:?]
Caused by: java.lang.NullPointerException: Cannot invoke "net.minecraft.server.MinecraftServer.method_3827()" because "this.minecraftServer" is null
at net.william278.husksync.FabricHuskSync.getMinecraftVersion(FabricHuskSync.java:336) ~[HuskSync-Fabric-3.7-2d56484+mc.1.21.1.jar:?]
at net.william278.husksync.util.CompatibilityChecker.checkCompatibility(CompatibilityChecker.java:53) ~[HuskSync-Fabric-3.7-2d56484+mc.1.21.1.jar:?]
at net.william278.husksync.FabricHuskSync.onInitializeServer(FabricHuskSync.java:124) ~[HuskSync-Fabric-3.7-2d56484+mc.1.21.1.jar:?]
at net.fabricmc.loader.impl.FabricLoaderImpl.invokeEntrypoints(FabricLoaderImpl.java:399) ~[fabric-loader-0.16.5.jar:?]
... 6 more
Protential Solution
After reviewing the source code, it appears the issue may stem from the checkCompatibility method using this.minecraftServer before it is initialized. Below is the relevant code snippet:
Description
When starting the Minecraft server with the HuskSync Fabric plugin, the server fails to start and throws a
NullPointerException
error.Version
Compiled from master branch, minecraft version 1.21.1
Server log
Protential Solution
After reviewing the source code, it appears the issue may stem from the
checkCompatibility
method usingthis.minecraftServer
before it is initialized. Below is the relevant code snippet:fabric/src/main/java/net/william278/husksync/FabricHuskSync.java