Skip to content

Commit 1a0616c

Browse files
committed
Fix respawn location not deemed as a bed location
1 parent 275181e commit 1a0616c

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ repositories {
4646

4747
dependencies {
4848
// Spigot
49-
implementation('org.bukkit:bukkit:1.14.4-R0.1-SNAPSHOT') {
49+
implementation('org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT') {
5050
exclude group: 'junit', module: 'junit'
5151
}
5252

src/main/java/org/mvplugins/multiverse/inventories/share/Sharables.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.mvplugins.multiverse.inventories.share;
22

33
import com.dumptruckman.minecraft.util.Logging;
4+
import org.bukkit.block.data.type.Bed;
45
import org.mvplugins.multiverse.core.teleportation.AsyncSafetyTeleporter;
56
import org.mvplugins.multiverse.inventories.MultiverseInventories;
67
import 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

Comments
 (0)