InventoryClickEvent

Discussion in 'Plugin Development' started by Ape101, Apr 23, 2014.

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

    Ape101

    So i've got this inv click listener, and everytime i click my item, i get a nullpoint exception.

    Code:java
    1. public void onClick(InventoryClickEvent e) {
    2. if (e.getWhoClicked() instanceof Player) {
    3. Player p = (Player) e.getWhoClicked();
    4.  
    5. if (e.getInventory().getName().equals(invname)) {
    6. e.setCancelled(true);
    7.  
    8. if (ArenaManager.getManager().getArena(arenaname) != null) {
    9. Arena arena = ArenaManager.getManager().getArena(arenaname);
    10. p.sendMessage("debug");
    11.  
    12. if (e.getCurrentItem().getItemMeta().getDisplayName()
    13. .equals(ChatColor.DARK_GREEN + "Start")) {


    obviously this isnt all my code but it should be enough, i get an nullpointer exception on line 88 which is line 12 in the picture, but there is no reason for it to be null, it has a name and has that specific name, im 100% sure of it, so whats wrong with it!?! :(
     
  2. Offline

    stink123456

    Is arena just a string?
     
  3. Offline

    finalblade1234

    Ape101 Perhaps check if the item in hand is null, then check if it hasItemMeta, and hasDisplayName
     
Thread Status:
Not open for further replies.

Share This Page