Railcraft

Railcraft

34M Downloads

Crash with BUKKIT caused by NPE

SeraphJACK opened this issue ยท 1 comments

commented

https://github.com/Railcraft/Railcraft/blob/mc-1.12.2/src/main/java/mods/railcraft/common/util/misc/Game.java#L69
here invokes Game.log() which will invoke Game.log("default")
https://github.com/Railcraft/Railcraft/blob/mc-1.12.2/src/main/java/mods/railcraft/common/util/misc/Game.java#L125
and here invokes enabledCategories::contains while enabledCategories is not initialized yet, and will throw NullPointerException.

I've done an experiment to proof that:

image

image

And in order to fix this, you just need to move the declaration before the static code block, or just simply initialize in the static code block.

Game Stack Trace:

net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Railcraft (railcraft)
Caused by: java.lang.ExceptionInInitializerError
	at mods.railcraft.common.modules.RailcraftModuleManager.loadModules(RailcraftModuleManager.java:55)
	at mods.railcraft.common.core.Railcraft.preInit(Railcraft.java:106)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:623)
	at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
	at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
	at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
	at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
	at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
	at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
	at com.google.common.eventbus.EventBus.post(EventBus.java:217)
	at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:219)
	at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:197)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91)
	at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150)
	at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76)
	at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399)
	at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71)
	at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116)
	at com.google.common.eventbus.EventBus.post(EventBus.java:217)
	at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:136)
	at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:627)
	at net.minecraftforge.fml.server.FMLServerHandler.beginServerLoading(FMLServerHandler.java:98)
	at net.minecraftforge.fml.common.FMLCommonHandler.onServerStart(FMLCommonHandler.java:333)
	at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(DedicatedServer.java:166)
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:599)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NullPointerException
	at mods.railcraft.common.util.misc.Game.log(Game.java:125)
	at mods.railcraft.common.util.misc.Game.log(Game.java:121)
	at mods.railcraft.common.util.misc.Game.<clinit>(Game.java:69)
	... 37 more
commented

@CovertJaguar Next time you should add fields to the front of a class.