Skip to content

Bug Report: If a custom item give player Material.AIR, the InventoryClickEvent will throw a null #1103

@GADDQ

Description

@GADDQ

Describe the bug

If you setup a custom item which give air to the player, buy message will not display, and buy sound will not play. It will give you these logs:

[15:08:32 ERROR]: Could not pass event InventoryClickEvent to BedWars1058 v25.2
org.bukkit.event.EventException: null
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[patched_1.8.8.jar:git-PaperSpigot-445]
        at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) ~[patched_1.8.8.jar:git-PaperSpigot-445]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[patched_1.8.8.jar:git-PaperSpigot-445]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:517) ~[patched_1.8.8.jar:git-PaperSpigot-445]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:502) ~[patched_1.8.8.jar:git-PaperSpigot-445]
        at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:1657) ~[patched_1.8.8.jar:git-PaperSpigot-445]
        at net.minecraft.server.v1_8_R3.PacketPlayInWindowClick.a(SourceFile:31) ~[patched_1.8.8.jar:git-PaperSpigot-445]
        at net.minecraft.server.v1_8_R3.PacketPlayInWindowClick.a(SourceFile:9) ~[patched_1.8.8.jar:git-PaperSpigot-445]
        at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) ~[patched_1.8.8.jar:git-PaperSpigot-445]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572) ~[?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:317) ~[?:?]
        at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44) ~[patched_1.8.8.jar:git-PaperSpigot-445]
        at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:774) ~[patched_1.8.8.jar:git-PaperSpigot-445]
        at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:378) ~[patched_1.8.8.jar:git-PaperSpigot-445]
        at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:713) ~[patched_1.8.8.jar:git-PaperSpigot-445]
        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:616) ~[patched_1.8.8.jar:git-PaperSpigot-445]
        at java.lang.Thread.run(Thread.java:1583) [?:?]
Caused by: java.lang.NullPointerException: Cannot invoke "net.minecraft.server.v1_8_R3.ItemStack.getItem()" because the return value of "org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack.asNMSCopy(org.bukkit.inventory.ItemStack)" is null
        at com.andrei1058.bedwars.support.version.v1_8_R3.v1_8_R3.isSword(v1_8_R3.java:153) ~[?:?]
        at com.andrei1058.bedwars.shop.main.BuyItem.give(BuyItem.java:251) ~[?:?]
        at com.andrei1058.bedwars.shop.main.CategoryContent.giveItems(CategoryContent.java:216) ~[?:?]
        at com.andrei1058.bedwars.shop.main.CategoryContent.execute(CategoryContent.java:192) ~[?:?]
        at com.andrei1058.bedwars.shop.listeners.InventoryListener.onInventoryClick(InventoryListener.java:109) ~[?:?]
        at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:580) ~[?:?]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:300) ~[patched_1.8.8.jar:git-PaperSpigot-445]
        ... 16 more

To Reproduce
Steps to reproduce the behavior:

Expected behavior

Should not throw an error, and buy message should be display, and buy sound should be play.

Screenshots

Not neccessary

System (please complete the following information):

  • OS: Windows Server
  • Server software paper
  • Server Version 1.8.8
  • Plugin Version 25.2

Additional context

You might ask "Why you try to give player air when they buy?", here's the reason:
bedwarsAPI didn't give me ability to set the material of item which player just got. I'm trying to make an special item which is non-physically exist, so the only way to do this is to give nothing to player. That's why i need to give air to the player.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions