Search code examples
bukkit

Is there a way to store yaw in player.BedSpawnLocation?


I'm making a 1.16.3 spigot plugin for a mini game. I want to setspawnpoint for each player individualy but I can't set it where I want.

I'm actualy using player.setBedSpawnLocation() but I need to store yaw and it don't look to save it.

code :

player.sendMessage("Spawn's location's yaw = " + spawn.getYaw());
player.setBedSpawnLocation(spawn, true);
player.sendMessage("Player spawn's location's yaw = " + player.getBedSpawnLocation().getYaw());

output :

// Spawn's location's yaw = 90.0
// Player spawn's location's yaw = 0.0

I know I could use player.teleport() when getting a playerDeath or playerSpawn event...(I've not checked event's name) but is there a better way ?

Thank's for your attention !


Solution

  • According to the craftbukkit sources, it's saved, but you can't get it. You can do a pull request, that might be helpful for a lot of people. https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java#751

    You'll have to store the location manually.