I want to set location when player respawn.
How can I set location on RespawnPlayerEvent in sponge 8.0 ?
Please help me.
I want to set location when player respawn.
How can I set location on RespawnPlayerEvent in sponge 8.0 ?
Please help me.
RespawnPlayerEvent has a few sub events, one of which is post
which happens after the player has spawned. For obvious reasons you cannot change it in the base class.
There is RespawnPlayerEvent.Recreate
which extends MoveEntityEvent therefore you can set the position in that. There is no docs on the class (yet) but my guess is that event is called when the player is recreated (Effectivly like a pre … but doesn’t include when a player is teleported to another world. When most people want to listen to a respawn event this is normally the pre
they want
It’s a two step process.
You first have to choose the world in RespawnPlayerEvent.SelectWorld
using setDestinationWorld
.
Then you can set the position in RespawnPlayerEvent.Recreate
using setDestinationPosition
.
Having this separation into two events may seem strange but it is a consequence of the way the game is implemented.
Thank for you care!
Thank you so much!