Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-5377

NullPointerException on InventoryClickEvent

XMLWordPrintable

    • This server is running CraftBukkit version git-Spigot-56f8471-606c19e (MC: 1.14.4) (Implementing API version 1.14.4-R0.1-SNAPSHOT)
    • Yes

      public class InventoryClickListener implements Listener {
      	
      	@EventHandler
      	public void handleInventoryClick(InventoryClickEvent e) {
      		e.getCurrentItem().getType(); //NullPointerException
      	}
      	
      	@EventHandler
      	public void handlePlayerJoin(PlayerJoinEvent e) {
      		Inventory inv = Bukkit.createInventory(e.getPlayer(), InventoryType.CHEST); //Other types are working too
      		e.getPlayer().openInventory(inv);
      	}}
      
      

      If you donĀ“t click on a block in fake inventories, getting the item type causes a NullPointerException. It should return Material.AIR if the player clicked on an empty slot and null if the player clicked outside the inventory or something similar.

            Unassigned Unassigned
            LaserSlimeHD LaserSlime
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: