Change spawnpoint

Hey,
I just completed the work on a little multi-world plugin for my server. I tested it a little bit and recognized something “strange”…
When I teleport a player to the spawn of “world” by using:

Optional<World> world = Sponge.getGame().getServer().getWorld("world");
player.setLocationSafely(world.get().getSpawnLocation());

The player gets not teleportet to the respawn point after he dies. The player did not use beds to change his respawn point. When I try it with different worlds, the same “bug” occurs.

//EDIT:
I found out, that you can change the spawnpoint with this code:
world.getProperties().setSpawnPosition(player.getLocation().getBlockPosition());

As well as world.getProperties().setSpawnPosition()
you can change the location when a RespawnPlayerEvent is fired (event.setToTransform())
you can also set the respawn locations for a single player with RespawnLocationData

2 Likes