Auto Respawn

Discussion in 'Spigot Plugin Development' started by Teh_Matt_GRyt, Jun 2, 2018.

  1. Auto Respawn on PlayerDeathEvent?
  2. Player.spigot.respawn();
  3. this code doesn't exist :/
  4. Can you post your code please?

    What version are you on and what part of the api are you using (spigot, bukkit etc)
  5. What version of the api are you using and what part? Bukkit, spigot, etc
  6. I use Bukkit 1.8
  7. #9 Teh_Matt_GRyt, Jun 2, 2018
    Last edited: Jun 2, 2018
  8. You see with you being in 1.8 Even though there is a plugin for 1.12.2 that gives pre 1.9 combat to 1.8 server. You dont have access to the new cool stuff spigot gave us.

    You could cancel the onPlayerDeath() event and call a new EntityResurrectEvent() casting the player as a LivingEntity.

    I could be wrong and it might need a little tuning. Im working on something and don't have time to build a test demo up. But if anyone else see's anything wrong with this let me know.
  9. Calling a EntityResurrectEvent won't make the player magically respawn. There is absolutely no reason you'd need to call this event yourself, it is already called at appropriate times internally.

    As for the actual issue at hand, switch to Spigot and a later version to make use of the new features or prepare yourself to use some nms.
  10. Code (Java):
  11. I don't think you can use PlayerDeathEvent to respawn auto respawn a player, you'll need to get EntityDamageEvent and check if it is a player, and if the player's health after damage is less than 0 then you can get them to respawn and set them to full health afterwards.
  12. WAHT i used playerdeathevent and playerrespawnevent in my plugin thepit a while ago. I set the players health to 20 on death and tped them to the spawn then added a runnable for the respawn event
  13. Maybe it changed since I last did it. I guess if you set the player health back to its max then cancel death message if you want, it will work. I just tested that out now.