From c8eec830b5a76d5fabb6cc5fd9ff684344466c15 Mon Sep 17 00:00:00 2001 From: Riley Park Date: Mon, 22 Feb 2021 03:12:40 -0800 Subject: [PATCH] fix #5217 --- Spigot-Server-Patches/0010-Adventure.patch | 8 ++++---- .../0234-InventoryCloseEvent-Reason-API.patch | 6 +++--- .../0453-Load-Chunks-for-Login-Asynchronously.patch | 6 +++--- Spigot-Server-Patches/0598-Add-API-for-quit-reason.patch | 8 ++++---- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Spigot-Server-Patches/0010-Adventure.patch b/Spigot-Server-Patches/0010-Adventure.patch index 7cf8a57648..100c6e5867 100644 --- a/Spigot-Server-Patches/0010-Adventure.patch +++ b/Spigot-Server-Patches/0010-Adventure.patch @@ -1096,7 +1096,7 @@ index 055555cb5ce63d41cb9a7f4114341b0685879b9e..7875d4c08969b3adc6f95504686cc9fe @Override diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java -index d34e91887cd73009bf852fb849e495a8affed7a9..b7346242ab1df88d33f33109aff6d21ebae052c6 100644 +index d34e91887cd73009bf852fb849e495a8affed7a9..6c759b295d1bdac25cd40713d7020fffa9d0fdb3 100644 --- a/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java @@ -25,6 +25,8 @@ import org.apache.logging.log4j.LogManager; @@ -1130,7 +1130,7 @@ index d34e91887cd73009bf852fb849e495a8affed7a9..b7346242ab1df88d33f33109aff6d21e return; } - String leaveMessage = EnumChatFormat.YELLOW + this.player.getName() + " left the game."; -+ net.kyori.adventure.text.Component leaveMessage = net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW); // Paper - Adventure ++ net.kyori.adventure.text.Component leaveMessage = net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, this.player.getBukkitEntity().displayName()); // Paper - Adventure - PlayerKickEvent event = new PlayerKickEvent(this.server.getPlayer(this.player), s, leaveMessage); + PlayerKickEvent event = new PlayerKickEvent(this.server.getPlayer(this.player), PaperAdventure.asAdventure(reason), leaveMessage); // Paper - Adventure @@ -1243,7 +1243,7 @@ index d34e91887cd73009bf852fb849e495a8affed7a9..b7346242ab1df88d33f33109aff6d21e } // CraftBukkit end diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java -index 5b49047b820dbe1f326320b71445ac216bf688b5..04d0749287803063c3cb3e92e44da873ceb044c0 100644 +index 5b49047b820dbe1f326320b71445ac216bf688b5..dc1055d6e59b455c026d1cf6a0ef8287f2e1ff0c 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -8,6 +8,7 @@ import com.mojang.authlib.GameProfile; @@ -1310,7 +1310,7 @@ index 5b49047b820dbe1f326320b71445ac216bf688b5..04d0749287803063c3cb3e92e44da873 } - PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), "\u00A7e" + entityplayer.getName() + " left the game"); -+ PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW)); ++ PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, entityplayer.getBukkitEntity().displayName())); cserver.getPluginManager().callEvent(playerQuitEvent); entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage()); diff --git a/Spigot-Server-Patches/0234-InventoryCloseEvent-Reason-API.patch b/Spigot-Server-Patches/0234-InventoryCloseEvent-Reason-API.patch index 03e069092d..29ac805845 100644 --- a/Spigot-Server-Patches/0234-InventoryCloseEvent-Reason-API.patch +++ b/Spigot-Server-Patches/0234-InventoryCloseEvent-Reason-API.patch @@ -88,7 +88,7 @@ index 3f559918e85b6d5c2ab8ff593b69d40c1db8bb16..d606e3faaf7c58d89539b6bd997978c0 this.o(); } diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java -index 5b6216e496256e27e2b53e807e5c7bff18e71014..1873ab094f43255c9eca64b3c1c4c6e0fbfe70cf 100644 +index 5c8e8a6c8e8e132240e38433e81698c4bc06e2a4..d7ab51834cbf4a1ea81c3ea610dcb23a8933d66a 100644 --- a/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java @@ -45,6 +45,7 @@ import org.bukkit.event.inventory.ClickType; @@ -117,7 +117,7 @@ index 5b6216e496256e27e2b53e807e5c7bff18e71014..1873ab094f43255c9eca64b3c1c4c6e0 this.player.o(); } diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java -index 872b780b337ba75448e679d544373df6d53c8fe4..cb6fa4be113d732ed93d9ccbef99c56f9044e7ee 100644 +index 0a7a1ad9d6d59261fe94e440abf06bdd19b6841f..dd3f3ead8e33b4db96226e1c86c019493326e4ac 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -423,7 +423,7 @@ public abstract class PlayerList { @@ -128,7 +128,7 @@ index 872b780b337ba75448e679d544373df6d53c8fe4..cb6fa4be113d732ed93d9ccbef99c56f + entityplayer.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DISCONNECT); // Paper } - PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW)); + PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, entityplayer.getBukkitEntity().displayName())); diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java index d192e341f0f6a3d03329dab16de3b19962091d2a..1a2760552cd42b302d4604917daf1fcd23765e59 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java diff --git a/Spigot-Server-Patches/0453-Load-Chunks-for-Login-Asynchronously.patch b/Spigot-Server-Patches/0453-Load-Chunks-for-Login-Asynchronously.patch index 905b264892..0caaaef63c 100644 --- a/Spigot-Server-Patches/0453-Load-Chunks-for-Login-Asynchronously.patch +++ b/Spigot-Server-Patches/0453-Load-Chunks-for-Login-Asynchronously.patch @@ -73,7 +73,7 @@ index e5790c2aeaa380a3acc26434f5de78ac746c6d57..bdd4766976902e11411728e6faa93b7e if (entityplayer != null) { this.g = LoginListener.EnumProtocolState.DELAY_ACCEPT; diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java -index 503b090870c4307ab11ef5fb7e2692863d7dc9ea..11e63ee879fa8eaa502981bf3fe7fa4f5a6f5668 100644 +index 7dda59329fe7cd3c675bdb433ff5a49a47cefa8d..d0d7225e6ec16c2e69c66a8f2f8702a82ed070cd 100644 --- a/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java @@ -76,6 +76,7 @@ public class PlayerConnection implements PacketListenerPlayIn { @@ -110,7 +110,7 @@ index 503b090870c4307ab11ef5fb7e2692863d7dc9ea..11e63ee879fa8eaa502981bf3fe7fa4f this.minecraftServer.getMethodProfiler().enter("keepAlive"); // Paper Start - give clients a longer time to respond to pings as per pre 1.12.2 timings diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java -index a45390e8a8782dc4295515aab033ba93a3a5a34b..992e3e932133c60b448ec62a322e74ef8deb7599 100644 +index 659efe4e9523e7d213a92ab616ce0594a55a3a9d..326be15831791a950c71ce8e0736ca67341b734c 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -56,11 +56,12 @@ public abstract class PlayerList { @@ -211,7 +211,7 @@ index a45390e8a8782dc4295515aab033ba93a3a5a34b..992e3e932133c60b448ec62a322e74ef @@ -449,7 +501,7 @@ public abstract class PlayerList { } - PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW)); + PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, entityplayer.getBukkitEntity().displayName())); - cserver.getPluginManager().callEvent(playerQuitEvent); + if (entityplayer.didPlayerJoinEvent) cserver.getPluginManager().callEvent(playerQuitEvent); // Paper - if we disconnected before join ever fired, don't fire quit entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage()); diff --git a/Spigot-Server-Patches/0598-Add-API-for-quit-reason.patch b/Spigot-Server-Patches/0598-Add-API-for-quit-reason.patch index 982206def1..f369248f22 100644 --- a/Spigot-Server-Patches/0598-Add-API-for-quit-reason.patch +++ b/Spigot-Server-Patches/0598-Add-API-for-quit-reason.patch @@ -37,7 +37,7 @@ index fc4ad72ffaed5e747cfecc71e9ac8ee2b556ce31..fb1e3c705b8abee13695762cdfd0e9f1 NetworkManager.LOGGER.debug("Failed to sent packet", throwable); this.sendPacket(new PacketPlayOutKickDisconnect(chatmessage), (future) -> { diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java -index 618675689dc22303a8f52f976dd89f07a299b221..f66201c839c25c101977628ac4b6f0f7eda5b2ca 100644 +index dea7787f755013fb06c1e9b999f4b6d167cb5697..9b36afad0974ad6f8a31f940bdbbf920c7859bb3 100644 --- a/src/main/java/net/minecraft/server/PlayerConnection.java +++ b/src/main/java/net/minecraft/server/PlayerConnection.java @@ -298,6 +298,7 @@ public class PlayerConnection implements PacketListenerPlayIn { @@ -49,15 +49,15 @@ index 618675689dc22303a8f52f976dd89f07a299b221..f66201c839c25c101977628ac4b6f0f7 this.networkManager.close(ichatbasecomponent); }); diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java -index 38c20c3f7c8a602770aceb9b561b7fb2eb3c86aa..4378e81421b766219908e4e15ffe4ab774c65f0e 100644 +index b0f432ed5ed47c867947a9285567a816da306797..27f6a9b0711a0e00c8350e45e2d0618b1f735eb8 100644 --- a/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java @@ -512,7 +512,7 @@ public abstract class PlayerList { entityplayer.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DISCONNECT); // Paper } -- PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW)); -+ PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW), entityplayer.quitReason); // Paper - quit reason +- PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, entityplayer.getBukkitEntity().displayName())); ++ PlayerQuitEvent playerQuitEvent = new PlayerQuitEvent(cserver.getPlayer(entityplayer), net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, entityplayer.getBukkitEntity().displayName()), entityplayer.quitReason); // Paper - quit reason if (entityplayer.didPlayerJoinEvent) cserver.getPluginManager().callEvent(playerQuitEvent); // Paper - if we disconnected before join ever fired, don't fire quit entityplayer.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage());