Add option to teleport to spawn if outside world border

This commit is contained in:
William Blake Galbreath
2025-01-07 16:57:11 -08:00
committed by granny
parent d2a0414806
commit bb8ed69b06
6 changed files with 48 additions and 75 deletions

View File

@@ -125,3 +125,30 @@
public ServerStatsCounter getStats() {
return this.stats;
@@ -3077,4 +_,26 @@
return (org.bukkit.craftbukkit.entity.CraftPlayer) super.getBukkitEntity();
}
// CraftBukkit end
+
+ // Purpur start - Add option to teleport to spawn if outside world border
+ public void teleport(org.bukkit.Location to) {
+ this.ejectPassengers();
+ this.stopRiding(true);
+
+ if (this.isSleeping()) {
+ this.stopSleepInBed(true, false);
+ }
+
+ if (this.containerMenu != this.inventoryMenu) {
+ this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.TELEPORT);
+ }
+
+ ServerLevel toLevel = ((org.bukkit.craftbukkit.CraftWorld) to.getWorld()).getHandle();
+ if (this.level() == toLevel) {
+ this.connection.teleport(to);
+ } else {
+ this.server.getPlayerList().respawn(this, true, RemovalReason.KILLED, org.bukkit.event.player.PlayerRespawnEvent.RespawnReason.DEATH, to);
+ }
+ }
+ // Purpur end - Add option to teleport to spawn if outside world border
}