SpongePowered / SpongeForge

A Forge mod that implements SpongeAPI
http://www.spongepowered.org/
MIT License
1.14k stars 306 forks source link

NPE in blood magic ritual help command #3019

Closed LemADEC closed 4 years ago

LemADEC commented 4 years ago

I am currently running

Issue Description When typing the blood magic help command, an error is reported for the ritual sub command, probably a bug in BloodMagic-1.12.2-2.4.3-105. However, with sponge, the error bubbles up to the player and prevents to see the remaining informations. Without sponge, the error is only reported in console and we can still see what's behind the commands.

Steps to reproduce: type /bloodmagic ritual help:

[20:16:53] [Server thread/INFO] [nucleus]: LemADEC ran the command: /bloodmagic ritual help
[20:16:53] [Server thread/ERROR] [Sponge]: Error occurred while executing command 'bloodmagic ritual help' for source EntityPlayerMP['LemADEC'/441, l='Pinky', x=-1263.50, y=68.00, z=-35.04]: java.lang.NullPoin
terException: id
java.lang.RuntimeException: java.lang.NullPointerException: id
>       at org.spongepowered.common.command.MinecraftCommandWrapper.tryExecute(MinecraftCommandWrapper.java:165) ~[MinecraftCommandWrapper.class:1.12.2-2838-7.1.8-RC3957]
>       at org.spongepowered.common.command.MinecraftCommandWrapper.process(MinecraftCommandWrapper.java:146) ~[MinecraftCommandWrapper.class:1.12.2-2838-7.1.8-RC3957]
>       at org.spongepowered.common.command.SpongeCommandDispatcher.process(SpongeCommandDispatcher.java:355) ~[SpongeCommandDispatcher.class:1.12.2-2838-7.1.8-RC3957]
>       at org.spongepowered.common.command.SpongeCommandManager.process(SpongeCommandManager.java:338) [SpongeCommandManager.class:1.12.2-2838-7.1.8-RC3957]
>       at net.minecraft.command.ServerCommandManager.func_71556_a(SourceFile:665) [dh.class:?]
>       at net.minecraft.network.NetHandlerPlayServer.func_147361_d(NetHandlerPlayServer.java:962) [pa.class:?]
>       at net.minecraft.network.NetHandlerPlayServer.func_147354_a(NetHandlerPlayServer.java:941) [pa.class:?]
>       at net.minecraft.network.play.client.CPacketChatMessage.func_148833_a(SourceFile:37) [la.class:?]
>       at net.minecraft.network.play.client.CPacketChatMessage.func_148833_a(SourceFile:9) [la.class:?]
>       at org.spongepowered.common.event.tracking.phase.packet.PacketPhaseUtil.onProcessPacket(PacketPhaseUtil.java:209) [PacketPhaseUtil.class:1.12.2-2838-7.1.8-RC3957]
>       at net.minecraft.network.PacketThreadUtil$1.redirect$impl$redirectToPhaseTracker$zld000(SourceFile:540) [hv$1.class:?]
>       at net.minecraft.network.PacketThreadUtil$1.run(SourceFile:13) [hv$1.class:?]
>       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_232]
>       at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_232]
>       at net.minecraft.util.Util.func_181617_a(SourceFile:46) [h.class:?]
>       at org.spongepowered.common.SpongeImplHooks.onUtilRunTask(SpongeImplHooks.java:308) [SpongeImplHooks.class:1.12.2-2838-7.1.8-RC3957]
>       at net.minecraft.server.MinecraftServer.redirect$onRun$zjh000(MinecraftServer.java:4716) [MinecraftServer.class:?]
>       at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:723) [MinecraftServer.class:?]
>       at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:397) [nz.class:?]
>       at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:668) [MinecraftServer.class:?]
>       at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526) [MinecraftServer.class:?]
>       at java.lang.Thread.run(Thread.java:748) [?:1.8.0_232]
Caused by: java.lang.NullPointerException: id
>       at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:787) ~[minecraft_server.1.12.2.jar:?]
>       at org.spongepowered.common.text.translation.SpongeTranslation.<init>(SpongeTranslation.java:41) ~[SpongeTranslation.class:1.12.2-2838-7.1.8-RC3957]
>       at net.minecraft.util.text.TextComponentTranslation.impl$createBuilder(SourceFile:552) ~[hp.class:?]
>       at net.minecraft.util.text.TextComponentBase.bridge$toText(TextComponentBase.java:699) ~[he.class:?]
>       at org.spongepowered.common.text.SpongeTexts.toText(SpongeTexts.java:83) ~[SpongeTexts.class:1.12.2-2838-7.1.8-RC3957]
>       at org.spongepowered.common.text.chat.ChatUtil.sendMessage(ChatUtil.java:50) ~[ChatUtil.class:1.12.2-2838-7.1.8-RC3957]
>       at net.minecraft.entity.player.EntityPlayerMP.func_145747_a(EntityPlayerMP.java:5156) ~[oq.class:?]
>       at net.minecraftforge.server.command.CommandTreeHelp.func_184881_a(CommandTreeHelp.java:68) ~[CommandTreeHelp.class:?]
>       at net.minecraftforge.server.command.CommandTreeBase.func_184881_a(CommandTreeBase.java:164) ~[CommandTreeBase.class:?]
>       at net.minecraftforge.server.command.CommandTreeBase.func_184881_a(CommandTreeBase.java:164) ~[CommandTreeBase.class:?]
>       at net.minecraft.command.CommandHandler.func_175786_a(CommandHandler.java:119) ~[bj.class:?]
>       at net.minecraft.command.CommandHandler.accessor$tryExecuteCommand(CommandHandler.java) ~[bj.class:?]
>       at org.spongepowered.common.command.MinecraftCommandWrapper.tryExecute(MinecraftCommandWrapper.java:161) ~[MinecraftCommandWrapper.class:1.12.2-2838-7.1.8-RC3957]
>       ... 21 more

In single player, there's an NPE but it's only visible in the logs and won't prevent execution of the remaining code.

[02:30:32] [Client thread/WARN]: Unexpected exception on ClientChatReceivedEvent: java.lang.NullPointerException
    at java.util.regex.Matcher.getTextLength(Matcher.java:1283)
    at java.util.regex.Matcher.reset(Matcher.java:309)
    at java.util.regex.Matcher.<init>(Matcher.java:229)
    at java.util.regex.Pattern.matcher(Pattern.java:1093)
    at net.minecraft.util.text.TextComponentTranslation.func_150269_b(SourceFile:64)
    at net.minecraft.util.text.TextComponentTranslation.func_150270_g(SourceFile:51)
    at net.minecraft.util.text.TextComponentTranslation.iterator(SourceFile:152)
    at net.minecraft.util.text.TextComponentBase.func_150254_d(TextComponentBase.java:82)
    at journeymap.client.forge.event.ChatEventHandler.invoke(ChatEventHandler.java:38)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_2902_ChatEventHandler_invoke_ClientChatReceivedEvent.invoke(.dynamic)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
    at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
    at net.minecraftforge.event.ForgeEventFactory.onClientChat(ForgeEventFactory.java:429)
    at net.minecraft.client.network.NetHandlerPlayClient.func_147251_a(NetHandlerPlayClient.java:843)
    at net.minecraft.network.play.server.SPacketChat.func_148833_a(SourceFile:41)
    at net.minecraft.network.play.server.SPacketChat.func_148833_a(SourceFile:10)
    at net.minecraft.network.PacketThreadUtil$1.run(SourceFile:13)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at net.minecraft.util.Util.func_181617_a(SourceFile:46)
    at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:1088)
    at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:398)
    at net.minecraft.client.main.Main.main(SourceFile:123)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

[02:30:32] [Client thread/INFO]: [CHAT] 
[02:30:32] [Client thread/INFO]: [CHAT] commands.bloodmagic.ritual.repair.usage
[02:30:32] [Client thread/INFO]: [CHAT] Creates the specified ritual with the MRS at your feet, ignores other blocks by default. (Optional parameters: ([<player> (safe|true|false)] | [safe|true|false]))
ImMorpheus commented 4 years ago

Blood magic is returning null here https://github.com/WayofTime/BloodMagic/blob/02d9b310a441ce36ae3179999ae4fe26d096e1af/src/main/java/WayofTime/bloodmagic/command/sub/SubCommandRitual.java#L37

As you said, the error is also there without Sponge.

LemADEC commented 4 years ago

I was hoping for better error handling in Sponge in such situation.