You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am creating plugin in version 1.20.4 paper (bukkit),
version dependencies:
com.comphenix.protocol
ProtocolLib
5.1.0
I added ProtocolLib.jar to my library, the specific version is v5.2.0-SNAPSHOT-679
4. Here my code:
private ProtocolManager protocolManager;
@Override
public void onEnable() {
if(getServer().getPluginManager().getPlugin("ProtocolLib") == null) {
getLogger().severe("ProtocolLib not found");
getServer().getPluginManager().disablePlugin(this);
return;
}
protocolManager = ProtocolLibrary.getProtocolManager();
protocolManager.addPacketListener(new PacketAdapter(this, PacketType.Handshake.Client.SET_PROTOCOL) {
@Override
public void onPacketReceiving(PacketEvent event) {
if(event.getPacketType() == PacketType.Handshake.Client.SET_PROTOCOL) {
int clientVersion = event.getPacket().getIntegers().read(0);
getLogger().info("Player " + event.getPlayer().getName() + " is using client version: " + clientVersion);
}
}
});
}
5. This is an error on the console:
Error occurred while enabling TempProtocol v1.0-Beta (Is it up to date?)
java.lang.NullPointerException: Cannot invoke "com.comphenix.protocol.ProtocolManager.addPacketListener(com.comphenix.protocol.events.PacketListener)" because "this.protocolManager" is null
at kanci.gamer.tempprotocol.TempProtocol.onEnable(TempProtocol.java:31) ~[TempProtocol-1.0-Beta.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:287) ~[paper-api-1.20.4-R0.1-SNAPSHOT.jar:?]
at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.enablePlugin(PaperPluginInstanceManager.java:188) ~[paper-1.20.4.jar:git-Paper-496]
6. This is the line that reports the error in the code, as I understand it:
Because I'm trying to connect dependencies with Protocol, my code is just that simple, it has all the libraries added (it doesn't error libraries or codes). I just declare a ProtocolManager and run it in onEnable.
com.comphenix.protocol
ProtocolLib
5.1.0
4. Here my code:
5. This is an error on the console:
6. This is the line that reports the error in the code, as I understand it:
protocolManager.addPacketListener(new PacketAdapter(this, PacketType.Handshake.Client.SET_PROTOCOL) {}
Please guide me how to fix this error. I'm new to programming minecraft plugins, please guide me. Thank people!
The text was updated successfully, but these errors were encountered: