onPlayerInteractEvent

Discussion in 'Plugin Development' started by tschagg, Mar 5, 2013.

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

    tschagg

    hey guys, i've a little problem with that event...
    Code:
      @EventHandler
      public void onPlayerInteractEvent(PlayerInteractEvent e){
        Player player = (Player) e.getPlayer();
        if(player.getItemInHand().hasItemMeta()){
        ItemStack iih = new ItemStack(player.getItemInHand());
        ItemMeta im = iih.getItemMeta();
        if (im.getDisplayName().equalsIgnoreCase(ChatColor.GOLD + "Weed Cookie")) {
              player.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION , 300, 1));
        }
      }
    }
    this gives me that errors:
    http://dpaste.com/1013004/

    any idea where the fault is?

    thank you!
     
  2. Offline

    xmarinusx

    What do you have on line 63?
     
  3. Offline

    tschagg

    on line 63 is a } the second last.
     
  4. It can't point to a } because it's a NPE, those don't throw NPEs.
    If you changed the code since the, re-export it and run it to generate the error again and look at the line.

    Also, why are you copying the item ? Just use player.getItemInHand().getItemMeta().

    You should also indent your code properly, it will help us and you to read it better.
     
Thread Status:
Not open for further replies.

Share This Page