Protocole Manager null
Zefix0509 opened this issue ยท 7 comments
The console said that my protocole manager is null. Do you know why?
I'm using the lastest build for version 1.18
I'm trying to add a listener on particules packets
Here's my code:
`@Override
public void onEnable() {
instance = this;
protocolManager = ProtocolLibrary.getProtocolManager();
protocolManager.addPacketListener(
new PacketAdapter(this, ListenerPriority.NORMAL,
PacketType.Play.Server.WORLD_PARTICLES) {
@Override
public void onPacketSending(PacketEvent event) {
System.out.println(event.getPlayer().getName() + " est le joueur en question: " + event.getPlayer().getUniqueId());
// Item packets (id: 0x29)
if (event.getPacketType() ==
PacketType.Play.Server.WORLD_PARTICLES && event.getPlayer().getUniqueId() == UUID.fromString("f1786fc3-9795-415a-a9c0-8538fd69fae8")) {
System.out.println(event.getPacketType().name());
event.setCancelled(true);
}
}
});
System.out.println("PacketParticule");
}`
I have the same issue
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
if (manager != null) {
manager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Client.ARM_ANIMATION) {
@Override
public void onPacketReceiving(PacketEvent event) {
super.onPacketReceiving(event);
onPlayerBreakStateChanges(event);
}
});
}
Code above is inside onEnable
and ProtocolLib
is provided as a hard dependency.
Can you provide us the stacktrace and more background information, like if you're depending on ProtocolLib etc?
or where this code is called. for example, if it's in onLoad
, you might not have access to the protocol manager. or in onEnable
, you may not be properly depending on PL
Another thing that came to my mind is that you're shading protocol lib into your plugin - don't do that. Put the plugin onto your server directly and depend on it.