ProtocolLibrary.getProtocolManager() is null (1.20)
Kyren223 opened this issue ยท 9 comments
- This issue is not solved in a development build
Describe the bug
ProtocolLibrary.getProtocolManager() returns null
To Reproduce
Steps to reproduce the behavior:
- Make a 1.20 plugin that uses ProtocolLib v5.0.0
- Put protocol lib plugin version 5.0.0 on the 1.20 spigot server
- Put the plugin created on that same spigot server
- Make the plugin invoke a method from ProtocolLibrary.getProtocolManager()
- See error (stack trace) in console saying the method cannot be invoked because the instance was null
Expected behavior
The ProtocolLibrary.getProtocolManager() method will return a valid instance of a ProtocolManager class (not null)
Version Info
https://pastebin.com/ETWBRRb8
You can scope the ProtocolLib dependency as provided
in your pom.xml
. Like so:
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>5.1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
I know two cases where this could occur.
Please validate that you
- Do not access
ProtocolLibrary.getProtocolManager()
inonLoad()
- Do not shade a copy of ProtocolLib into your plugin. In this case,
ProtocolLibrary.getProtocolManager()
will try to access the shaded copy of ProtocolLib, which will never be initialized because it is not loaded as a plugin.
- I access the method in a util function that is called only when a condition is met in a server event
- How can I determine if I shade a copy of ProtocolLib? I might be doing it
Also I was using another plugin (someone else made) that also requires ProtocolLib and it had the same error
- Okay, then this should not be the issue.
- The easiest way is to open the Jar of your plugin with e.g. WinRAR or 7Zip and check if there is a com/comphenix/ Folder inside. This folder should be only in the ProtocolLib.jar.
This doesn't seem to solve my issue, here's the exact exception:
Cannot invoke "com.comphenix.protocol.ProtocolManager.createPacket(com.comphenix.protocol.PacketType)" because "pm" is null
I checked the jar and it now only contains my package (no com package)
And the exact same error seemed to happen to another plugin api for 1.19
I think the issue is running it on 1.20