1.16.5 I can't understand a word of these errors...

Discussion in 'Spigot Plugin Development' started by CrossedLivid, Jun 18, 2021.

  1. Understanding stacktraces is not only vital for any half-competent Java programmer, but also quite easy. It is understandable that the perceived uglyness can be confusing, though, so let's go through the first stacktrace and try to make sense of it.

    Code (Text):

    [13:52:28] [Server thread/ERROR]: Error occurred while enabling NPCPlugin v1.0 (Is it up to date?)
    org.bukkit.plugin.IllegalPluginAccessException: java.lang.NullPointerException
           at org.bukkit.plugin.SimplePluginManager.getEventListeners(SimplePluginManager.java:663) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
           at org.bukkit.plugin.SimplePluginManager.registerEvents(SimplePluginManager.java:616) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
           at net.wardensmp.plugins.dev.npc.NPCPlugin.onEnable(NPCPlugin.java:17) ~[?:?]
           at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
           at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
           at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
           at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:492) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
           at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:406) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
           at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:554) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
           at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:257) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
           at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:928) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
           at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$0(MinecraftServer.java:273) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
           at java.lang.Thread.run(Thread.java:829) [?:?]
     
    Error occurred while enabling NPCPlugin - this already tells us there is something wrong with the onEnable method. What exactly? java.lang.NullPointerException --> something is null when it should not be.

    Now the general procedure is to go through the lines one by one and find the first that belongs to your code, not the the Bukkit API. I am guessing it is this one: at net.wardensmp.plugins.dev.npc.NPCPlugin.onEnable(NPCPlugin.java:17) ~[?:?]
    This line contains all the missing information. What is says is that there is a class called NPCPlugin within the net.wardensmp.plugins.dev.npc package, and the exception is thrown somewhere in the onEnable method. Where exactly? At line 17, so start by looking there.

    The second exceptions may appear scarier but is also quite simple.

    Code (Text):

    [*][13:53:56] [Server thread/ERROR]: Could not pass event PlayerQuitEvent to NPCPlugin v1.0
    [*]org.bukkit.event.EventException: null
    [*]at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
    [*]at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
    [*]at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:589) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
    [*]at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:576) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
    [*]at net.minecraft.server.v1_16_R3.PlayerList.disconnect(PlayerList.java:487) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
    [*]at net.minecraft.server.v1_16_R3.PlayerConnection.a(PlayerConnection.java:1637) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
    [*]at net.minecraft.server.v1_16_R3.NetworkManager.handleDisconnection(NetworkManager.java:333) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
    [*]at net.minecraft.server.v1_16_R3.ServerConnection.c(ServerConnection.java:163) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
    [*]at net.minecraft.server.v1_16_R3.MinecraftServer.b(MinecraftServer.java:1246) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
    [*]at net.minecraft.server.v1_16_R3.DedicatedServer.b(DedicatedServer.java:394) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
    [*]at net.minecraft.server.v1_16_R3.MinecraftServer.a(MinecraftServer.java:1127) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
    [*]at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:966) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
    [*]at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$0(MinecraftServer.java:273) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
    [*]at java.lang.Thread.run(Thread.java:829) [?:?]
    [*]Caused by: java.lang.NullPointerException
    [*]at net.wardensmp.plugins.dev.npc.PacketReader.uninject(PacketReader.java:42) ~[?:?]
    [*]at net.wardensmp.plugins.dev.npc.JoinEvent.onPlayerQuit(JoinEvent.java:25) ~[?:?]
    [*]at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
    [*]at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
    [*]at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
    [*]at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
    [*]at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-1.16.5.jar:3096-Spigot-9fb885e-296df56]
    [*]... 13 more
    [*]
    This is another NullPointerException. Skip to Caused by: java.lang.NullPointerException: find the first line that belongs to you (net.wardensmp.plugins.dev.npc.PacketReader.uninject(PacketReader.java:42) ~[?:?]), then find line 42 of PacketReader.
    The obvious issue would be that

    Code (Text):
    channel = channels.get(player.getUniqueId());
    // channel is null <-------------------------------------------------- !!!!
    if (channel.pipeline().get("PacketInjector") != null) { // NPE
    // ...
    }
     
     
    • Like Like x 3
  2. so i think that the null pointer exception comes from the RightClickNPC's e.getPlayer(), where the player might have been undefined.

    it seems that the PacketReader's readPacket() method was never called...? i dont know...

    i followed this tutorial on youtube btw:


    for the second problem, i have know idea how to fix it lmao.

    ^because an exception is thrown, injection wasnt complete so inject wasnt called?

    Can you please help me @Lori00 ?

    hmm perhaps i have to inject first then register.
     
  3. NEVERMIND. it still has the error. @Lori00