ProtocolLib

3M Downloads

java.lang.NullPointerException

luanmenglei opened this issue · 4 comments

commented

Describe the bug
WrappedBlockData.createData(Material.SIGN_POST) I use this to create a BlockData
and here are the errors:

Caused by: java.lang.NullPointerException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_241]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_241]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_241]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_241]
at com.comphenix.protocol.reflect.accessors.DefaultMethodAccessor.invoke(DefaultMethodAccessor.java:16) ~[?:?]
at com.comphenix.protocol.wrappers.WrappedBlockData$OldBlockData.createOldData(WrappedBlockData.java:238) ~[?:?]
at com.comphenix.protocol.wrappers.WrappedBlockData$OldBlockData.access$400(WrappedBlockData.java:164) ~[?:?]
at com.comphenix.protocol.wrappers.WrappedBlockData.createData(WrappedBlockData.java:300) ~[?:?]

Version Info
ProtocolLib 4.4 & ProtocolLib 4.5

commented

It's works perfectly on ProtocolLib4.3

commented

I was going to post the same bug so i guess i'll post it here to avoid the spam

Describe the bug
I am getting a NullPointerException while trying to call an api method;
WrappedBlockData.createData(Material.WALL_SIGN);
Error log:

[14:52:20 WARN]: Caused by: java.lang.NullPointerException
[14:52:20 WARN]:        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[14:52:20 WARN]:        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[14:52:20 WARN]:        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[14:52:20 WARN]:        at java.lang.reflect.Method.invoke(Unknown Source)
[14:52:20 WARN]:        at com.comphenix.protocol.reflect.accessors.DefaultMethodAccessor.invoke(DefaultMethodAccessor.java:16)
[14:52:20 WARN]:        at com.comphenix.protocol.wrappers.WrappedBlockData$OldBlockData.createOldData(WrappedBlockData.java:238)
[14:52:20 WARN]:        at com.comphenix.protocol.wrappers.WrappedBlockData$OldBlockData.access$400(WrappedBlockData.java:164)
[14:52:20 WARN]:        at com.comphenix.protocol.wrappers.WrappedBlockData.createData(WrappedBlockData.java:300)
[14:52:20 WARN]:        at fr.hugo4715.spigot.util.gui.SignInputManager.open(SignInputManager.java:44)
[14:52:20 WARN]:        at fr.hugo4715.spigot.commands.impl.staff.TestCommand.onTest(TestCommand.java:15)
[14:52:20 WARN]:        ... 22 more

To Reproduce
Call WrappedBlockData.createData(Material.WALL_SIGN);

Expected behavior
I excepted a WrappedBlockData to be created.

Screenshots
Not applicable

Version Info
https://pastebin.com/5rahu2en

Additional context
I am trying to open the sign gui for a player to input text.

        WrapperPlayServerBlockChange blockChangePacket = new WrapperPlayServerBlockChange();
        WrappedBlockData blockData = WrappedBlockData.createData(Material.WALL_SIGN);
        blockChangePacket.setBlockData(blockData);
        blockChangePacket.setLocation(pos);
        blockChangePacket.sendPacket(player);

commented

@luanmenglei @hugo4715 as a debug step, can you try calling WrappedBlockData.createData(Material.WALL_SIGN, 0); instead and see if that works?

commented

@luanmenglei @hugo4715 as a debug step, can you try calling WrappedBlockData.createData(Material.WALL_SIGN, 0); instead and see if that works?

It works perfectly with that fix 🥇
Thanks