Want a better Minecraft server? Read about SpigotMC here!
Separate names with a comma.
Discussion in 'Spigot Plugin Development' started by Teh_Matt_GRyt, Jun 2, 2018.
Auto Respawn on PlayerDeathEvent?
this code doesn't exist :/
Can you post your code please?
What version are you on and what part of the api are you using (spigot, bukkit etc)
uhm.... ok https://pastebin.com/iyAAT5LH
What version of the api are you using and what part? Bukkit, spigot, etc
I use Bukkit 1.8
Try checking this:
Have you tried using nms?
No I haven't tried. and also it doesn't works the code on the https://bukkit.org/threads/bypass-respawn-screen.89891/#post-1483748 and when i put it on the event the CraftPlayer for some reason doesn't allow me to import it... any1 else for help?
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.
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.
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.
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
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.