Solved Hunger Not Being Set?

Discussion in 'Spigot Plugin Development' started by Orionweblab, Apr 22, 2017.

  1. I'm trying to make a instant respawn!
    It works with the exception that it won't set the hunger to full!
    (everything else works except hunger setting)
    Code (Text):
         @EventHandler
         public void onKill(EntityDamageByEntityEvent e){
             if(e.getEntityType() == EntityType.PLAYER){
                 Player player = (Player) e.getEntity();
                 if(e.getDamage() >= player.getHealth()){
                     player.setHealth(20);
                     player.setSaturation(0.0f);
                     player.teleport(player.getWorld().getSpawnLocation());
                 }
             }
         }
     
  2. Check if your event is firing, if not, ensure the following:
    • The class implements Listener
    • In onEnable() you register that same class.
     
  3. I made sure everything else is working like if you get damaged I had a test message but everything else works except hunger
     
    • Agree Agree x 1
  4. No problem. Just mark this thread as solved.