Solved Need help with Protocol Lib Packet Listener

Discussion in 'Plugin Development' started by TheBrightnessMan, Aug 11, 2020.

Thread Status:
Not open for further replies.
  1. I planned to make an NPC plugin with packets using Protocol Lib, but I keep getting a Null Pointer Exception when I tried to listen on packets.

    This is my main class (I removed some of the code irrelevant to my issue)
    Code:
    public class Main extends JavaPlugin {
    
        public void onEnable() {
              packetListener();
         }
    
       
    private void packetListener() {
            ProtocolManager manager = ProtocolLibrary.getProtocolManager();
            manager.addPacketListener(
                    new PacketAdapter(this, PacketType.Play.Client.USE_ENTITY) {
    
                        @Override
                        public void onPacketReceiving(PacketEvent event) {
                            Bukkit.broadcastMessage("a");
                            super.onPacketReceiving(event);
                        }
                    }
            );
        }
    
    The Null Pointer Exception message in the console says the error occurred in line 133, which is
    manager.addPacketListener

    Thanks in advance
     
  2. Offline

    timtower Administrator Administrator Moderator

  3. oh I totally forgot about that

    thread marked as SOLVED
     
Thread Status:
Not open for further replies.

Share This Page