Solved Onconsume error

Discussion in 'Plugin Development' started by xelatercero, Jun 13, 2016.

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

    xelatercero

    I have a consume event, works great but when i consome another thing like chicken, apple, milk, i have an error

    Code:
        @EventHandler
        public void onConsumeSpeed(PlayerItemConsumeEvent e) {
            Player p = e.getPlayer();
            String meta = e.getItem().getItemMeta().getDisplayName();
           
            if(meta.equalsIgnoreCase("UP speed")) {
                p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 12000, 2));
               
               
            } 
           
        }
     
  2. Online

    timtower Administrator Administrator Moderator

    @xelatercero You are assuming that there is meta data and that there is a displayname.
    Please check if they exist before you use them.
     
  3. Offline

    xelatercero

Thread Status:
Not open for further replies.

Share This Page