Solved Problems with Soup Healing

Discussion in 'Spigot Plugin Development' started by Remy2402, Apr 24, 2016.

  1. Heyo!

    So I am in the progress of creating a KitPvP plugin. All is going well so far but I am having troubles with the soups that you right click to get health. When you receive your kit, my plugin fills the remaining open space in the player's inventory with soup. But, it seems that only the soup that was originally placed in the hotbar works.

    I hope you get what I mean but I am really stumped on why it seems to be doing this. Thanks in advance for any help!
     
  2. Could you send us the code or any errors given?
     
  3. Works for me:
    Code (Text):
    @EventHandler
        public void onSoup(PlayerInteractEvent e) {  
                Player p = e.getPlayer();
               
                if(p.getInventory().getItemInMainHand().getType().equals(Material.MUSHROOM_SOUP)) {
                   
                    if(e.getAction().equals(Action.RIGHT_CLICK_AIR)
                            || e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
                       
                        if(p.getHealth() == 20) {
                            return;
                        }
                       
                        p.getInventory().getItemInMainHand().setType(Material.BOWL);
                        if(p.getHealth() <= 19 - boost) {
                            p.setHealth(p.getHealth() + boost);
                        } else {
                            p.setHealth(20);
                        }
                       
                    }
                }
               
            }
           
        }
     
  4. Let me try your version out and see if it works. Will get back to you :)
     
  5. Works! I was using e.getItem instead of p.getItemInHand. Thank you!