11package org .mvplugins .multiverse .inventories .share ;
22
33import com .dumptruckman .minecraft .util .Logging ;
4+ import org .bukkit .block .data .type .Bed ;
45import org .mvplugins .multiverse .core .teleportation .AsyncSafetyTeleporter ;
56import org .mvplugins .multiverse .inventories .MultiverseInventories ;
67import org .mvplugins .multiverse .inventories .WorldGroup ;
@@ -490,7 +491,20 @@ public boolean updatePlayer(Player player, PlayerProfile profile) {
490491 public void updateProfile (PlayerProfile profile , Player player ) {
491492 Location bedSpawnLocation = null ;
492493 try {
494+ Logging .finer ("profile bed: " + player .getBedSpawnLocation ());
493495 bedSpawnLocation = player .getBedSpawnLocation ();
496+
497+ var blockBedSpawnLocation = bedSpawnLocation .getBlock ().getLocation ();
498+ for (int x = -1 ; x <= 1 ; x ++) {
499+ for (int z = -1 ; z <= 1 ; z ++) {
500+ var newBedLoc = blockBedSpawnLocation .clone ().add (x , 0 , z );
501+ Logging .finest ("new bed: " + newBedLoc );
502+ if (newBedLoc .getBlock ().getBlockData () instanceof Bed ) {
503+ bedSpawnLocation = newBedLoc ;
504+ break ;
505+ }
506+ }
507+ }
494508 } catch (NullPointerException e ) {
495509 // TODO this is a temporary fix for the bug occurring in 1.16.X CB/Spigot/Paper
496510 StackTraceElement [] stackTrace = e .getStackTrace ();
@@ -513,6 +527,7 @@ public boolean updatePlayer(Player player, PlayerProfile profile) {
513527 return false ;
514528 }
515529 player .setBedSpawnLocation (loc , true );
530+ Logging .finer ("update bed: " + player .getBedSpawnLocation ());
516531 return true ;
517532 }
518533 }).serializer (new ProfileEntry (false , DataStrings .PLAYER_BED_SPAWN_LOCATION ), new LocationSerializer ())
0 commit comments