From fd9350e9ba1046e61c917b9adeda96a176830974 Mon Sep 17 00:00:00 2001 From: Aikar Date: Sun, 19 Apr 2020 03:11:02 -0400 Subject: [PATCH] Clean up duplicate PlayerInitialSpawnEvent Confused on this one, as commit history says Spigots version is older than our version, so i'm not sure how we ended up duplicating this when the 2 events are 100% identical. Subclass spigots event and rely on the inheritance system, and clean up the duplicate event fires. Fix Spigots setPosition to use setPositionRaw to avoid chunk load prematurely. --- .../Add-PlayerInitialSpawnEvent.patch | 47 ++++--------------- .../Add-PlayerInitialSpawnEvent.patch | 38 +++++++-------- .../Broadcast-join-message-to-console.patch | 2 +- ...oggleEvent-when-whitelist-is-toggled.patch | 2 +- .../Configurable-Player-Collision.patch | 8 ++-- ...move-existing-players-to-world-spawn.patch | 15 ++++-- .../Enforce-Sync-Player-Saves.patch | 2 +- .../Entity-getEntitySpawnReason.patch | 8 ++-- ...g-Broken-behavior-of-PlayerJoinEvent.patch | 2 +- Spigot-Server-Patches/Fix-MC-158900.patch | 2 +- ...dDebugInfo-not-initialized-on-client.patch | 2 +- ...-sneak-when-changing-worlds-MC-10657.patch | 4 +- ...Crash-support-and-Improve-Async-Shut.patch | 2 +- .../Implement-PlayerPostRespawnEvent.patch | 2 +- .../InventoryCloseEvent-Reason-API.patch | 16 +++---- ...0-Fix-Whitelist-On-Off-inconsistency.patch | 4 +- ...nilla-per-world-scoreboard-coloring-.patch | 6 +-- .../ProfileWhitelistVerifyEvent.patch | 2 +- ...le-async-calls-to-restart-the-server.patch | 6 +-- ...ets-from-world-player-list-not-serve.patch | 2 +- 20 files changed, 74 insertions(+), 98 deletions(-) diff --git a/Spigot-API-Patches/Add-PlayerInitialSpawnEvent.patch b/Spigot-API-Patches/Add-PlayerInitialSpawnEvent.patch index 147127befd..0c4b1f47c3 100644 --- a/Spigot-API-Patches/Add-PlayerInitialSpawnEvent.patch +++ b/Spigot-API-Patches/Add-PlayerInitialSpawnEvent.patch @@ -7,7 +7,7 @@ For modifying a player's initial spawn location as they join the server diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerInitialSpawnEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerInitialSpawnEvent.java new file mode 100644 -index 000000000..8e407eff1 +index 00000000..8b1fdb9d --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerInitialSpawnEvent.java @@ -0,0 +0,0 @@ @@ -15,47 +15,16 @@ index 000000000..8e407eff1 + +import org.bukkit.Location; +import org.bukkit.entity.Player; -+import org.bukkit.event.HandlerList; -+import org.bukkit.event.player.PlayerEvent; +import org.jetbrains.annotations.NotNull; ++import org.spigotmc.event.player.PlayerSpawnLocationEvent; + -+public class PlayerInitialSpawnEvent extends PlayerEvent { -+ private static final HandlerList handlers = new HandlerList(); -+ @NotNull private Location spawnLocation; ++/** ++ * @deprecated Use {@link PlayerSpawnLocationEvent}, Duplicate API ++ */ ++public class PlayerInitialSpawnEvent extends PlayerSpawnLocationEvent { + -+ public PlayerInitialSpawnEvent(@NotNull final Player player, @NotNull final Location spawnLocation) { -+ super(player); -+ this.spawnLocation = spawnLocation; -+ } -+ -+ /** -+ * Gets the current spawn location -+ * -+ * @return Location current spawn location -+ */ -+ @NotNull -+ public Location getSpawnLocation() { -+ return this.spawnLocation; -+ } -+ -+ /** -+ * Sets the new spawn location -+ * -+ * @param spawnLocation new location for the spawn -+ */ -+ public void setSpawnLocation(@NotNull Location spawnLocation) { -+ this.spawnLocation = spawnLocation; -+ } -+ -+ @NotNull -+ @Override -+ public HandlerList getHandlers() { -+ return handlers; -+ } -+ -+ @NotNull -+ public static HandlerList getHandlerList() { -+ return handlers; ++ public PlayerInitialSpawnEvent(@NotNull Player who, @NotNull Location spawnLocation) { ++ super(who, spawnLocation); + } +} -- \ No newline at end of file diff --git a/Spigot-Server-Patches/Add-PlayerInitialSpawnEvent.patch b/Spigot-Server-Patches/Add-PlayerInitialSpawnEvent.patch index 49234c022f..8d10cf22cc 100644 --- a/Spigot-Server-Patches/Add-PlayerInitialSpawnEvent.patch +++ b/Spigot-Server-Patches/Add-PlayerInitialSpawnEvent.patch @@ -5,30 +5,28 @@ Subject: [PATCH] Add PlayerInitialSpawnEvent For modifying a player's initial spawn location as they join the server +This is a duplicate API from spigot, so use our duplicate subclass and +improve setPosition to use raw + diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java -index 1652a57e25..948a6e3b7a 100644 +index f28be11ee..541e3ce83 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -0,0 +0,0 @@ public abstract class PlayerList { - } - // CraftBukkit end -- entityplayer.spawnIn(worldserver); -+ // Paper start - support PlayerInitialSpawnEvent -+ Location originalLoc = new Location(entityplayer.world.getWorld(), entityplayer.locX(), entityplayer.locY(), entityplayer.locZ(), entityplayer.yaw, entityplayer.pitch); -+ com.destroystokyo.paper.event.player.PlayerInitialSpawnEvent event = new com.destroystokyo.paper.event.player.PlayerInitialSpawnEvent(entityplayer.getBukkitEntity(), originalLoc); -+ this.server.server.getPluginManager().callEvent(event); -+ -+ Location newLoc = event.getSpawnLocation(); -+ entityplayer.world = ((CraftWorld) newLoc.getWorld()).getHandle(); -+ entityplayer.setPositionRaw(newLoc.getX(), newLoc.getY(), newLoc.getZ()); -+ entityplayer.yaw = newLoc.getYaw(); -+ entityplayer.pitch = newLoc.getPitch(); -+ entityplayer.dimension = ((CraftWorld) newLoc.getWorld()).getHandle().worldProvider.getDimensionManager(); -+ // Paper end -+ -+ entityplayer.spawnIn(((CraftWorld) newLoc.getWorld()).getHandle()); - entityplayer.playerInteractManager.a((WorldServer) entityplayer.world); - String s1 = "local"; + // Spigot start - spawn location event + Player bukkitPlayer = entityplayer.getBukkitEntity(); +- PlayerSpawnLocationEvent ev = new PlayerSpawnLocationEvent(bukkitPlayer, bukkitPlayer.getLocation()); ++ PlayerSpawnLocationEvent ev = new com.destroystokyo.paper.event.player.PlayerInitialSpawnEvent(bukkitPlayer, bukkitPlayer.getLocation()); // Paper use our duplicate event + Bukkit.getPluginManager().callEvent(ev); + + Location loc = ev.getSpawnLocation(); + worldserver = ((CraftWorld) loc.getWorld()).getHandle(); + + entityplayer.spawnIn(worldserver); +- entityplayer.setPosition(loc.getX(), loc.getY(), loc.getZ()); ++ entityplayer.setPositionRaw(loc.getX(), loc.getY(), loc.getZ()); // Paper - set raw so we aren't fully joined to the world (not added to chunk or world) + entityplayer.setYawPitch(loc.getYaw(), loc.getPitch()); + // Spigot end -- \ No newline at end of file diff --git a/Spigot-Server-Patches/Broadcast-join-message-to-console.patch b/Spigot-Server-Patches/Broadcast-join-message-to-console.patch index 3117624979..45f58af6d2 100644 --- a/Spigot-Server-Patches/Broadcast-join-message-to-console.patch +++ b/Spigot-Server-Patches/Broadcast-join-message-to-console.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Broadcast join message to console diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java -index 0e1703c9d..72ca7f706 100644 +index 160476fa2..7403be0b2 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -0,0 +0,0 @@ public abstract class PlayerList { diff --git a/Spigot-Server-Patches/Call-WhitelistToggleEvent-when-whitelist-is-toggled.patch b/Spigot-Server-Patches/Call-WhitelistToggleEvent-when-whitelist-is-toggled.patch index 9e26603989..19323683f6 100644 --- a/Spigot-Server-Patches/Call-WhitelistToggleEvent-when-whitelist-is-toggled.patch +++ b/Spigot-Server-Patches/Call-WhitelistToggleEvent-when-whitelist-is-toggled.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Call WhitelistToggleEvent when whitelist is toggled diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java -index 89d34716fe..4b3083499b 100644 +index f71c9f4a8..e9908cd01 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -0,0 +0,0 @@ public abstract class PlayerList { diff --git a/Spigot-Server-Patches/Configurable-Player-Collision.patch b/Spigot-Server-Patches/Configurable-Player-Collision.patch index c38e5223ce..66a1743629 100644 --- a/Spigot-Server-Patches/Configurable-Player-Collision.patch +++ b/Spigot-Server-Patches/Configurable-Player-Collision.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Configurable Player Collision diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java -index d500cd75a9..e4f0db64c0 100644 +index d500cd75a..e4f0db64c 100644 --- a/src/main/java/com/destroystokyo/paper/PaperConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java @@ -0,0 +0,0 @@ public class PaperConfig { @@ -19,7 +19,7 @@ index d500cd75a9..e4f0db64c0 100644 + } } diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 3094f763ba..deffa2ddbd 100644 +index 1d3f1be24..f82be54cc 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant> { @@ -23,7 +23,7 @@ index 8570e38f42..c97be42dd7 100644 this.e = flag; } diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java -index 4d6ac8f85c..89d34716fe 100644 +index e148940ab..f71c9f4a8 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -0,0 +0,0 @@ public abstract class PlayerList { diff --git a/Spigot-Server-Patches/Option-to-use-vanilla-per-world-scoreboard-coloring-.patch b/Spigot-Server-Patches/Option-to-use-vanilla-per-world-scoreboard-coloring-.patch index aa9a0176d1..7b088111de 100644 --- a/Spigot-Server-Patches/Option-to-use-vanilla-per-world-scoreboard-coloring-.patch +++ b/Spigot-Server-Patches/Option-to-use-vanilla-per-world-scoreboard-coloring-.patch @@ -12,7 +12,7 @@ for this on CB at one point but I can't find it. We may need to do this ourselves at some point in the future. diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java -index 47f5f8055e..b1d1a3c1f8 100644 +index 47f5f8055..b1d1a3c1f 100644 --- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java @@ -0,0 +0,0 @@ public class PaperWorldConfig { @@ -26,7 +26,7 @@ index 47f5f8055e..b1d1a3c1f8 100644 + } } diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java -index 505189c82b..669d9a41d6 100644 +index 505189c82..669d9a41d 100644 --- a/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java @@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn { @@ -48,7 +48,7 @@ index 505189c82b..669d9a41d6 100644 if (((LazyPlayerSet) event.getRecipients()).isLazy()) { for (Object recipient : minecraftServer.getPlayerList().players) { diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java -index 05ea0ace58..94a24a49cf 100644 +index 9691d84f2..9212501b8 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -0,0 +0,0 @@ public abstract class PlayerList { diff --git a/Spigot-Server-Patches/ProfileWhitelistVerifyEvent.patch b/Spigot-Server-Patches/ProfileWhitelistVerifyEvent.patch index 91a8a7d3ca..e9e74c72f2 100644 --- a/Spigot-Server-Patches/ProfileWhitelistVerifyEvent.patch +++ b/Spigot-Server-Patches/ProfileWhitelistVerifyEvent.patch @@ -5,7 +5,7 @@ Subject: [PATCH] ProfileWhitelistVerifyEvent diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java -index 308bc3baf2..002f7e844a 100644 +index 77f1ddc8a..a61815c79 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -0,0 +0,0 @@ public abstract class PlayerList { diff --git a/Spigot-Server-Patches/Properly-handle-async-calls-to-restart-the-server.patch b/Spigot-Server-Patches/Properly-handle-async-calls-to-restart-the-server.patch index 9d27f2b0e1..b4a72a1b7c 100644 --- a/Spigot-Server-Patches/Properly-handle-async-calls-to-restart-the-server.patch +++ b/Spigot-Server-Patches/Properly-handle-async-calls-to-restart-the-server.patch @@ -30,7 +30,7 @@ will have plugins and worlds saving to the disk has a high potential to result in corruption/dataloss. diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index bdc98d12c6..e41352681a 100644 +index ebb41f788..af2fa93d4 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java @@ -0,0 +0,0 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant