Stack Trace NPE

Discussion in 'Spigot Plugin Development' started by DidactCraft, Jun 21, 2015.

  1. whats on the line?
    PHP:
    Caused by: java.lang.NullPointerException
            at me.Imperial.Gkit.Main.inventoryClickEvent(Main.java:234) ~[?:?]
     
  2. Caused by: java.lang.NullPointerException
    at me.Imperial.Gkit.Main.pyro(Main.java:194) ~[?:?]
    at me.Imperial.Gkit.Main.inventoryClickEvent(Main.java:241) ~[?:?]

    Caused by line 241 in Main.java
     
  3. This is whats on the line:
    pyro.pyro(p);

    I have the code I pasted above in a separate class so I can call for it :)
     
  4. ok then whats on the lines that @LPkkjHD said?
     
  5. New stack trace: http://pastebin.com/d0P9nUh8
     
  6. line?
    PHP:
    Caused by: java.lang.NullPointerException
            at me.Imperial.Gkit.Main.inventoryClickEvent(Main.java:155) ~[?:?]
     
  7. @EventHandler
    public void inventoryClickEvent(InventoryClickEvent e) {

    final Player p = (Player) e.getWhoClicked();
    PlayerInventory pi = p.getInventory();
    Player p2 = (Player) e.getWhoClicked();

    if (e.getSlot() == -1) {
    e.setCancelled(true);
    }

    if (!e.getCurrentItem().hasItemMeta()) {
    return;
    }

    if (e.getCurrentItem().getItemMeta().getDisplayName()
    .contains("§6§lPyroKit")) {
    e.setCancelled(true);
    pyro.pyro(p);

    }

    }
    }

    155 line is pyro.pyro(p);
     
  8. just a dumb question (maybe)
    could it be cuz its
    PHP:
    public void pyro(final Player p) {
    and u need to check if its a player?
     
  9. Why would I need to check if it was a player? The Player p = e.getWhoClicked(); will be a player no matter what because nothing else can run a command and open a GUI.
     
  10. i did say