Everything works fine, but when ever a player drops something out of their inventory while they have this menu open It causes an error. Why is this happing? And how do I fix it? Code:java // Inventory Handler @EventHandler public void BibMenuInv(InventoryClickEvent e) { Player pl = (Player) e.getWhoClicked(); if (!e.getInventory().getName() .equalsIgnoreCase(this.getBibMenuInv().getName())) return; if (e.getInventory().getName() == null) { return; } if (!e.getCurrentItem().hasItemMeta()) { return; } if (e.getCurrentItem().getItemMeta() == null) { return; } In the error log it's telling me that my error is located on line 59 which is Code:java if (!e.getCurrentItem().hasItemMeta()) { return; }
I believe that pressing Q is counted as "clicking" the inventory. If the item is dropped, there is no longer an item there, and therefore e.getCurrentItem() returns null, causing a NullPointerException. 1. Check the action that is performed first. 2. Check the Item and make sure that it isn't == null.
Bib Take a look at this: http://jd.bukkit.org/dev/apidocs/org/bukkit/event/inventory/ClickType.html You can get the ClickType by using event.getClick()
Hmm did a few things like that and it didn't work. Code:java if (e.getCurrentItem().equals(null)) { return; } I don't think any of that works for a bukkit inventory EDIT by Moderator: merged posts, please use the edit button instead of double posting.