spigot/CraftBukkit-Patches/0048-Implement-PlayerSpawnLocationEvent.patch
2025-07-14 19:28:46 +10:00

33 lines
1.8 KiB
Diff

From 3e4cd1f977cddfd5c17e1d518243ba899d396893 Mon Sep 17 00:00:00 2001
From: ninja <xninja@openmailbox.org>
Date: Tue, 8 Apr 2014 14:05:19 +0200
Subject: [PATCH] Implement PlayerSpawnLocationEvent.
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index c3e1bc943..bf68c7b46 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -221,6 +221,19 @@ public abstract class PlayerList {
worldserver1.waitForChunkAndEntities(entityplayer.chunkPosition(), 1);
String s1 = networkmanager.getLoggableAddress(this.server.logIPs());
+ // Spigot start - spawn location event
+ Player spawnPlayer = entityplayer.getBukkitEntity();
+ org.spigotmc.event.player.PlayerSpawnLocationEvent ev = new org.spigotmc.event.player.PlayerSpawnLocationEvent(spawnPlayer, spawnPlayer.getLocation());
+ cserver.getPluginManager().callEvent(ev);
+
+ Location loc = ev.getSpawnLocation();
+ worldserver1 = ((CraftWorld) loc.getWorld()).getHandle();
+
+ entityplayer.spawnIn(worldserver1, true);
+ entityplayer.gameMode.setLevel((WorldServer) entityplayer.level());
+ entityplayer.absSnapTo(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
+ // Spigot end
+
// CraftBukkit - Moved message to after join
// PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ({}, {}, {})", new Object[]{entityplayer.getName().getString(), s1, entityplayer.getId(), entityplayer.getX(), entityplayer.getY(), entityplayer.getZ()});
WorldData worlddata = worldserver1.getLevelData();
--
2.50.1