Solved Error

Discussion in 'Spigot Plugin Development' started by Giorgino, Feb 17, 2020.

  1. Error:
    Code (Text):
    [15:29:08] [Server thread/ERROR]: Could not pass event InventoryCreativeEvent to Creative v0.1
    org.bukkit.event.EventException: null
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:320) ~[1.15.2.jar:git-Spigot-800b93f-8160e29]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[1.15.2.jar:git-Spigot-800b93f-8160e29]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:529) ~[1.15.2.jar:git-Spigot-800b93f-8160e29]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:514) ~[1.15.2.jar:git-Spigot-800b93f-8160e29]
            at net.minecraft.server.v1_15_R1.PlayerConnection.a(PlayerConnection.java:2303) ~[1.15.2.jar:git-Spigot-800b93f-8160e29]
            at net.minecraft.server.v1_15_R1.PacketPlayInSetCreativeSlot.a(SourceFile:23) ~[1.15.2.jar:git-Spigot-800b93f-8160e29]
            at net.minecraft.server.v1_15_R1.PacketPlayInSetCreativeSlot.a(SourceFile:9) ~[1.15.2.jar:git-Spigot-800b93f-8160e29]
            at net.minecraft.server.v1_15_R1.PlayerConnectionUtils.lambda$0(PlayerConnectionUtils.java:19) ~[1.15.2.jar:git-Spigot-800b93f-8160e29]
            at net.minecraft.server.v1_15_R1.TickTask.run(SourceFile:18) [1.15.2.jar:git-Spigot-800b93f-8160e29]
            at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.executeTask(SourceFile:144) [1.15.2.jar:git-Spigot-800b93f-8160e29]
            at net.minecraft.server.v1_15_R1.IAsyncTaskHandlerReentrant.executeTask(SourceFile:23) [1.15.2.jar:git-Spigot-800b93f-8160e29]
            at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.executeNext(SourceFile:118) [1.15.2.jar:git-Spigot-800b93f-8160e29]
            at net.minecraft.server.v1_15_R1.MinecraftServer.ba(MinecraftServer.java:918) [1.15.2.jar:git-Spigot-800b93f-8160e29]
            at net.minecraft.server.v1_15_R1.MinecraftServer.executeNext(MinecraftServer.java:911) [1.15.2.jar:git-Spigot-800b93f-8160e29]
            at net.minecraft.server.v1_15_R1.IAsyncTaskHandler.awaitTasks(SourceFile:127) [1.15.2.jar:git-Spigot-800b93f-8160e29]
            at net.minecraft.server.v1_15_R1.MinecraftServer.sleepForTick(MinecraftServer.java:895) [1.15.2.jar:git-Spigot-800b93f-8160e29]
            at net.minecraft.server.v1_15_R1.MinecraftServer.run(MinecraftServer.java:828) [1.15.2.jar:git-Spigot-800b93f-8160e29]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_241]
    Caused by: java.lang.NullPointerException
            at creative.events.CreativeEvent.onCreative(CreativeEvent.java:85) ~[?:?]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_241]
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_241]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_241]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_241]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:316) ~[1.15.2.jar:git-Spigot-800b93f-8160e29]
            ... 17 more

    Code (Java):
    Line 85: m1meta.setDisplayName("Test");

            ItemStack m1 = new ItemStack(e.getCursor().getType());
            ItemMeta m1meta = m1.getItemMeta();
            m1meta.setDisplayName("Test");
            e.getCursor().setItemMeta(m1meta);

    Practically when I take the item from the creative, and put it in the bar the name is replaced with "Test" but when I click again to throw it away it gives me this error.
     
  2. SteelPhoenix

    Moderator

    You are assuming the player has an item on the cursor and that it has meta
     
    • Winner Winner x 1
  3. Do you check if item is not null and it's type is not AIR?
     
    • Winner Winner x 1
  4. Hm ... no. Anyway thank you very much, I solved it.
    (I'm so bad)