Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ repositories {

dependencies {
// Spigot
implementation('org.bukkit:bukkit:1.14.4-R0.1-SNAPSHOT') {
implementation('org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT') {
exclude group: 'junit', module: 'junit'
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.mvplugins.multiverse.inventories.share;

import com.dumptruckman.minecraft.util.Logging;
import org.bukkit.block.data.type.Bed;
import org.mvplugins.multiverse.core.teleportation.AsyncSafetyTeleporter;
import org.mvplugins.multiverse.inventories.MultiverseInventories;
import org.mvplugins.multiverse.inventories.WorldGroup;
Expand All @@ -16,6 +17,7 @@
import org.bukkit.potion.PotionEffect;
import org.mvplugins.multiverse.core.economy.MVEconomist;

import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
Expand Down Expand Up @@ -490,7 +492,8 @@ public boolean updatePlayer(Player player, PlayerProfile profile) {
public void updateProfile(PlayerProfile profile, Player player) {
Location bedSpawnLocation = null;
try {
bedSpawnLocation = player.getBedSpawnLocation();
Logging.finer("profile bed: " + player.getBedSpawnLocation());
bedSpawnLocation = findBedFromRespawnLocation(player.getBedSpawnLocation());
} catch (NullPointerException e) {
// TODO this is a temporary fix for the bug occurring in 1.16.X CB/Spigot/Paper
StackTraceElement[] stackTrace = e.getStackTrace();
Expand All @@ -513,11 +516,29 @@ public boolean updatePlayer(Player player, PlayerProfile profile) {
return false;
}
player.setBedSpawnLocation(loc, true);
Logging.finer("updating bed: " + player.getBedSpawnLocation());
return true;
}
}).serializer(new ProfileEntry(false, DataStrings.PLAYER_BED_SPAWN_LOCATION), new LocationSerializer())
.altName("bedspawn").altName("bed").altName("beds").altName("bedspawns").build();

private static @Nullable Location findBedFromRespawnLocation(@Nullable Location respawnLocation) {
if (respawnLocation == null) {
return null;
}
var blockBedSpawnLocation = respawnLocation.getBlock().getLocation();
for(int x = -1; x <= 1; x++) {
for(int z = -1; z <= 1; z++) {
var newBedLoc = blockBedSpawnLocation.clone().add(x, 0, z);
Logging.finest("Finding bed at: " + newBedLoc);
if (newBedLoc.getBlock().getBlockData() instanceof Bed) {
return newBedLoc;
}
}
}
return respawnLocation;
}

/**
* Sharing Last Location.
*/
Expand Down
Loading