2020-09-10 20:35:41 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ivan Pekov <ivan@mrivanplays.com>
Date: Thu, 10 Sep 2020 21:16:40 +0300
Subject: [PATCH] Respect PlayerKickEvent leaveMessage
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
2020-11-07 08:02:33 +01:00
index c0ef5a9e1224f2bc55f42e6c879ab7cb21e2eff6..f7afa92333ab173446edafd93eb4845829425b40 100644
2020-09-10 20:35:41 +02:00
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
2020-11-07 08:02:33 +01:00
@@ -319,7 +319,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
2020-09-10 20:35:41 +02:00
this.networkManager.sendPacket(new PacketPlayOutKickDisconnect(ichatbasecomponent), (future) -> {
this.networkManager.close(ichatbasecomponent);
});
- this.a(ichatbasecomponent); // CraftBukkit - fire quit instantly
2020-10-06 17:59:16 +02:00
+ this.a(ichatbasecomponent, event.getLeaveMessage().equalsIgnoreCase(leaveMessage) ? null : event.getLeaveMessage()); // CraftBukkit - fire quit instantly // Yatopia
2020-09-10 20:35:41 +02:00
this.networkManager.stopReading();
MinecraftServer minecraftserver = this.minecraftServer;
NetworkManager networkmanager = this.networkManager;
2020-11-07 08:02:33 +01:00
@@ -1677,6 +1677,11 @@ public class PlayerConnection implements PacketListenerPlayIn {
2020-09-10 20:35:41 +02:00
@Override
public void a(IChatBaseComponent ichatbasecomponent) {
+ // Yatopia start - added quitMessage parameter
+ a(ichatbasecomponent, null);
+ }
+ public void a(IChatBaseComponent ichatbasecomponent, String quitMessage) {
+ // Yatopia end
// CraftBukkit start - Rarely it would send a disconnect line twice
if (this.processedDisconnect) {
return;
2020-11-07 08:02:33 +01:00
@@ -1692,7 +1697,7 @@ public class PlayerConnection implements PacketListenerPlayIn {
2020-09-10 20:35:41 +02:00
*/
this.player.p();
- String quitMessage = this.minecraftServer.getPlayerList().disconnect(this.player);
+ quitMessage = this.minecraftServer.getPlayerList().disconnect(this.player, quitMessage); // Yatopia
if ((quitMessage != null) && (quitMessage.length() > 0)) {
this.minecraftServer.getPlayerList().sendMessage(CraftChatMessage.fromString(quitMessage));
}
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
2020-10-06 16:26:45 +02:00
index 01b3904fd813f98048396f5b4c041f35d3b395c4..41fb2bcd6c4a2c99ff5f71d059c5485eaa3a6193 100644
2020-09-10 20:35:41 +02:00
--- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java
2020-10-06 16:26:45 +02:00
@@ -499,6 +499,11 @@ public abstract class PlayerList {
2020-09-10 20:35:41 +02:00
}
public String disconnect(EntityPlayer entityplayer) { // CraftBukkit - return string
+ // Yatopia start - add quitMessage parameter
+ return disconnect(entityplayer, null);
+ }
+ public String disconnect(EntityPlayer entityplayer, String quitMessage) {
+ // Yatopia end
WorldServer worldserver = entityplayer.getWorldServer();
entityplayer.a(StatisticList.LEAVE_GAME);
2020-10-06 16:26:45 +02:00
@@ -587,7 +592,7 @@ public abstract class PlayerList {
2020-09-10 20:35:41 +02:00
cserver.getScoreboardManager().removePlayer(entityplayer.getBukkitEntity());
// CraftBukkit end
- return entityplayer.didPlayerJoinEvent ? playerQuitEvent.getQuitMessage() : null; // CraftBukkit // Paper - don't print quit if we never printed join
+ return entityplayer.didPlayerJoinEvent ? quitMessage != null ? quitMessage : playerQuitEvent.getQuitMessage() : null; // CraftBukkit // Paper - don't print quit if we never printed join // Yatopia
}
// CraftBukkit start - Whole method, SocketAddress to LoginListener, added hostname to signature, return EntityPlayer