ProtocolLib

3M Downloads

Data watchers broken in 1.20.5+

Ghost-chu opened this issue · 5 comments

commented
  • This issue is not solved in a development build

Describe the bug
A clear and concise description of what the bug is.

WrappedDataWatcher object unable to create.

To Reproduce
Steps to reproduce the behavior:

WrappedDataWatcher wpw = new WrappedDataWatcher();

And logs will appears:

java.lang.NullPointerException: constructor
        at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:921) ~[guava-32.1.2-jre.jar:?]
        at ProtocolLib (3).jar/com.comphenix.protocol.reflect.accessors.MethodHandleHelper.getConstructorAccessor(MethodHandleHelper.java:70) ~[ProtocolLib (3).jar:?]
        at ProtocolLib (3).jar/com.comphenix.protocol.reflect.accessors.Accessors.getConstructorAccessor(Accessors.java:167) ~[ProtocolLib (3).jar:?]
        at ProtocolLib (3).jar/com.comphenix.protocol.reflect.accessors.Accessors.getConstructorAccessor(Accessors.java:145) ~[ProtocolLib (3).jar:?]
        at ProtocolLib (3).jar/com.comphenix.protocol.wrappers.WrappedDataWatcher.newHandle(WrappedDataWatcher.java:118) ~[ProtocolLib (3).jar:?]
        at ProtocolLib (3).jar/com.comphenix.protocol.wrappers.WrappedDataWatcher.<init>(WrappedDataWatcher.java:82) ~[ProtocolLib (3).jar:?]
        at QuickShop-Hikari-6.2.0.3.jar/com.ghostchu.quickshop.shop.display.virtual.packetfactory.v1_20_R4.createFakeItemMetaPacket(v1_20_R4.java:86) ~[QuickShop-Hikari-6.2.0.3.jar:?]
        at QuickShop-Hikari-6.2.0.3.jar/com.ghostchu.quickshop.shop.display.virtual.packetfactory.v1_20_R4.testFakeItem(v1_20_R4.java:44) ~[QuickShop-Hikari-6.2.0.3.jar:?]
        at QuickShop-Hikari-6.2.0.3.jar/com.ghostchu.quickshop.util.envcheck.EnvironmentChecker.virtualDisplayWorkingTest(EnvironmentChecker.java:358) ~[QuickShop-Hikari-6.2.0.3.jar:?]
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[?:?]
        at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[?:?]
        at QuickShop-Hikari-6.2.0.3.jar/com.ghostchu.quickshop.util.envcheck.EnvironmentChecker.run(EnvironmentChecker.java:262) ~[QuickShop-Hikari-6.2.0.3.jar:?]
        at QuickShop-Hikari-6.2.0.3.jar/com.ghostchu.quickshop.QuickShop.runtimeCheck(QuickShop.java:335) ~[QuickShop-Hikari-6.2.0.3.jar:?]
        at QuickShop-Hikari-6.2.0.3.jar/com.ghostchu.quickshop.QuickShop.onEnable(QuickShop.java:659) ~[QuickShop-Hikari-6.2.0.3.jar:?]
        at QuickShop-Hikari-6.2.0.3.jar/com.ghostchu.quickshop.QuickShopBukkit.onEnable(QuickShopBukkit.java:101) ~[QuickShop-Hikari-6.2.0.3.jar:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:287) ~[paper-api-1.20.6-R0.1-SNAPSHOT.jar:?]
        at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.enablePlugin(PaperPluginInstanceManager.java:202) ~[paper-1.20.6.jar:1.20.6-137-bd5867a]
        at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.enablePlugin(PaperPluginManagerImpl.java:109) ~[paper-1.20.6.jar:1.20.6-137-bd5867a]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:519) ~[paper-api-1.20.6-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.CraftServer.enablePlugin(CraftServer.java:604) ~[paper-1.20.6.jar:1.20.6-137-bd5867a]
        at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:553) ~[paper-1.20.6.jar:1.20.6-137-bd5867a]
        at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:675) ~[paper-1.20.6.jar:1.20.6-137-bd5867a]
        at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:437) ~[paper-1.20.6.jar:1.20.6-137-bd5867a]
        at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:323) ~[paper-1.20.6.jar:1.20.6-137-bd5867a]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1136) ~[paper-1.20.6.jar:1.20.6-137-bd5867a]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:323) ~[paper-1.20.6.jar:1.20.6-137-bd5867a]
        at java.base/java.lang.Thread.run(Thread.java:1583) ~[?:?]

Expected behavior
A clear and concise description of what you expected to happen.

WrappedDataWatcher correctly created without exception

Screenshots
If applicable, add screenshots to help explain your problem.

Version Info
Provide your ProtocolLib install info with /protocol dump through pastebin.

https://paste.gg/p/anonymous/00ca6584d3f84d88a77a43d949c93995

Additional context
Add any other context about the problem here.

> version
[18:39:09 INFO]: Checking version, please wait...
[18:39:11 INFO]: This server is running Paper version 1.20.6-137-master@bd5867a (2024-06-04T21:04:28Z) (Implementing API version 1.20.6-R0.1-SNAPSHOT)
You are running the latest version
>
commented

There were some significant changes to data watchers in 1.20.5... will use this issue to track progress in fixing those

commented

Latest version fixes declaring the data watcher but apparently the registry is now null when trying to create watchable objects.

Error:
java.lang.NullPointerException: Cannot invoke "com.comphenix.protocol.reflect.accessors.MethodAccessor.invoke(Object, Object[])" because "com.comphenix.protocol.wrappers.WrappedDataWatcher.REGISTER" is null

Code:
WrappedDataWatcher dataWatcher = new WrappedDataWatcher();
dataWatcher.setObject( new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), (byte) (0x20)); <---- Error

commented

@seraph-prisons try the latest dev build and let me know. it seems to work in the unit tests. also, are you using Spigot or Paper?

commented

Sorry for the late response, works perfectly now! Good job. (I'm on latest paper snapshot)

commented

This actually still seems to be an issue for 1.8.8 servers. Even with latest dev build (723).

java.lang.NullPointerException: constructor
    at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:229) ~[paper.jar:git-PaperSpigot-445]
    at com.comphenix.protocol.reflect.accessors.MethodHandleHelper.getConstructorAccessor(MethodHandleHelper.java:70) ~[?:?]
    at com.comphenix.protocol.reflect.accessors.Accessors.getConstructorAccessor(Accessors.java:167) ~[?:?]
    at com.comphenix.protocol.reflect.accessors.Accessors.getConstructorAccessor(Accessors.java:145) ~[?:?]
    at com.comphenix.protocol.wrappers.LegacyDataWatcher.newHandle(LegacyDataWatcher.java:113) ~[?:?]
    at com.comphenix.protocol.wrappers.LegacyDataWatcher.<init>(LegacyDataWatcher.java:108) ~[?:?]
    at com.comphenix.protocol.wrappers.LegacyDataWatcher.<init>(LegacyDataWatcher.java:85) ~[?:?]
    at com.comphenix.protocol.wrappers.WrappedDataWatcher.<init>(WrappedDataWatcher.java:86) ~[?:?]