Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to find NMS class: DataWatcherRegistry #166

Open
rmue11er opened this issue Aug 3, 2019 · 3 comments
Open

Failed to find NMS class: DataWatcherRegistry #166

rmue11er opened this issue Aug 3, 2019 · 3 comments

Comments

@rmue11er
Copy link

rmue11er commented Aug 3, 2019

Hello,
I get this error on my spigot 1.8.8 server whenever is use a Plugin that uses ProtocolLib.

RuntimeException: Failed to find NMS class: DataWatcherRegistry

ProtocolLib itself loads without an error.
the error occurs for example when I do the following:

acketContainer packet = protocolManager.createPacket(PacketType.Play.Server.SPAWN_ENTITY);

		WrapperPlayServerEntityMetadata packet2 = new WrapperPlayServerEntityMetadata();
		// Set the entity to associate the packet with, which in this case is the client-side entity we created before.
		packet2.setEntityId(78);
		// Create a ProtocolLib WrappedDataWatcher from the entity's current metadata.
		WrappedDataWatcher dataWatcher = new WrappedDataWatcher(packet2.getEntityMetadata());
		WrappedDataWatcher.WrappedDataWatcherObject isInvisibleIndex = new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class));
		dataWatcher.setObject(isInvisibleIndex, (byte) 0x20);
		WrappedDataWatcher.WrappedDataWatcherObject nameValue = new WrappedDataWatcher.WrappedDataWatcherObject(2, WrappedDataWatcher.Registry.get(String.class));
		WrappedDataWatcher.WrappedDataWatcherObject nameVisible = new WrappedDataWatcher.WrappedDataWatcherObject(3, WrappedDataWatcher.Registry.get(Boolean.class));

		dataWatcher.setObject(nameValue, "§aHello, " + p.getDisplayName() + "!");
		dataWatcher.setObject(nameVisible, true);
		packet2.setEntityMetadata(dataWatcher.getWatchableObjects());
		packet2.sendPacket(p);

Full error:

Caused by: java.lang.RuntimeException: Failed to find NMS class: DataWatcherRegistry
at com.comphenix.protocol.utility.MinecraftReflection.lambda$getMinecraftClass$1(MinecraftReflection.java:2025) ~[?:?]
at java.util.Optional.orElseThrow(Optional.java:290) ~[?:1.8.0_212]
at com.comphenix.protocol.utility.MinecraftReflection.getMinecraftClass(MinecraftReflection.java:2025) ~[?:?]
at com.comphenix.protocol.utility.MinecraftReflection.getDataWatcherRegistryClass(MinecraftReflection.java:1372) ~[?:?]
at com.comphenix.protocol.wrappers.WrappedDataWatcher$Registry.initialize(WrappedDataWatcher.java:994) ~[?:?]
at com.comphenix.protocol.wrappers.WrappedDataWatcher$Registry.get(WrappedDataWatcher.java:932) ~[?:?]
at de.krextiv.test.modules.connect.JoinQuitEvent.rankDisplay(JoinQuitEvent.java:48) ~[?:?]
at de.krextiv.test.modules.connect.JoinQuitEvent.onJoin(JoinQuitEvent.java:117) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_212]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_212]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_212]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_212]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[server.jar:git-Spigot-21fe707-e1ebe52]
... 14 more

using the latest protocollib version available for download that says that it is for 1.8 version.

@dmulloy2
Copy link
Collaborator

dmulloy2 commented Aug 4, 2019

Yeah so you have to use the old data watcher setup without the registry on 1.8. should be examples around but I'm on mobile

@Ultra03
Copy link

Ultra03 commented May 19, 2020

@dmulloy2 Sorry to bring up a relatively old issue, but where can I find these examples? I've been searching around for a while but haven't found anything.

@dmulloy2
Copy link
Collaborator

@Ultra03 it looks like the old examples have vanished (likely to do with curse forge redoing their website). The gist of it is that the old API was a lot simpler than the new one -- you don't have to worry about the watcher registry or anything like that. Take a look at the WrappedDataWatcher and the WrappedWatchableObject docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants