ProtocolLib

3M Downloads

java.lang.NullPointerException: Cannot invoke

SufkopGamer opened this issue ยท 7 comments

commented

This is my code:

private void registerPacketListeners() { ProtocolLibrary.getProtocolManager().addPacketListener((PacketListener)new ClientMoveHandler.PacketListening((Plugin)this)); ProtocolLibrary.getProtocolManager().addPacketListener((PacketListener)new ClientEntityUnmountListener((Plugin)this)); ProtocolLibrary.getProtocolManager().addPacketListener((PacketListener)new MountListener(this)); }

This is my error:

java.lang.NullPointerException: Cannot invoke "com.comphenix.protocol.ProtocolManager.addPacketListener(com.comphenix.protocol.events.PacketListener)" because the return value of "com.comphenix.protocol.ProtocolLibrary.getProtocolManager()" is null

commented

Hi,
you're either not depending on ProtocolLib or you accidentally shaded ProtocolLib into your plugin.

commented

Just make sure that (if you are using maven) the ProtocolLib dependency scope is provided (if you are using gradle use compileOnly over implementation or api)

commented

How do you mean?

I use ProtocolLib for Packets and PacketEvents

commented

image
This is the whole error

commented

Thx

commented

I use Maven how can is provided it?

commented
  <dependency>
    <groupId>com.comphenix.protocol</groupId>
    <artifactId>ProtocolLib</artifactId>
    <version>4.8.0</version>
    <scope>provided</scope>
  </dependency>

Like this