Discussion in 'Plugin Development' started by Bib, Aug 23, 2014.

Thread Status:
Not open for further replies.
  1. Offline


    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?

    1. // Inventory Handler
    2. @EventHandler
    3. public void BibMenuInv(InventoryClickEvent e) {
    4. Player pl = (Player) e.getWhoClicked();
    5. if (!e.getInventory().getName()
    6. .equalsIgnoreCase(this.getBibMenuInv().getName()))
    7. return;
    8. if (e.getInventory().getName() == null) {
    9. return;
    10. }
    11. if (!e.getCurrentItem().hasItemMeta()) {
    12. return;
    13. }
    14. if (e.getCurrentItem().getItemMeta() == null) {
    15. return;
    16. }

    In the error log it's telling me that my error is located on line 59 which is
    2. if (!e.getCurrentItem().hasItemMeta()) {
    3. return;
    4. }
  2. Offline


    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.
  3. Offline


  4. Offline


    Hmm did a few things like that and it didn't work.
    2. if (e.getCurrentItem().equals(null)) {
    3. return;
    4. }

    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.
    Last edited by a moderator: Jun 10, 2016
Thread Status:
Not open for further replies.

Share This Page