#1338: Introduce getRespawnLocation as a replacement for getBedSpawnLocation

This commit is contained in:
Nothixal 2024-01-22 20:27:09 +11:00 committed by md_5
parent fb973486c2
commit b93c5a30d2
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11
2 changed files with 20 additions and 0 deletions

View File

@ -297,6 +297,11 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
@Override @Override
public Location getBedSpawnLocation() { public Location getBedSpawnLocation() {
return getRespawnLocation();
}
@Override
public Location getRespawnLocation() {
NBTTagCompound data = getData(); NBTTagCompound data = getData();
if (data == null) return null; if (data == null) return null;

View File

@ -1008,6 +1008,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override @Override
public Location getBedSpawnLocation() { public Location getBedSpawnLocation() {
return getRespawnLocation();
}
@Override
public Location getRespawnLocation() {
WorldServer world = getHandle().server.getLevel(getHandle().getRespawnDimension()); WorldServer world = getHandle().server.getLevel(getHandle().getRespawnDimension());
BlockPosition bed = getHandle().getRespawnPosition(); BlockPosition bed = getHandle().getRespawnPosition();
@ -1026,8 +1031,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
setBedSpawnLocation(location, false); setBedSpawnLocation(location, false);
} }
@Override
public void setRespawnLocation(Location location) {
setRespawnLocation(location, false);
}
@Override @Override
public void setBedSpawnLocation(Location location, boolean override) { public void setBedSpawnLocation(Location location, boolean override) {
setRespawnLocation(location, override);
}
@Override
public void setRespawnLocation(Location location, boolean override) {
if (location == null) { if (location == null) {
getHandle().setRespawnPosition(null, null, 0.0F, override, false, PlayerSpawnChangeEvent.Cause.PLUGIN); getHandle().setRespawnPosition(null, null, 0.0F, override, false, PlayerSpawnChangeEvent.Cause.PLUGIN);
} else { } else {