diff --git a/patches/api/0018-Add-reason-to-PlayerConnectionCloseEvent.patch b/patches/api/0018-Add-reason-to-PlayerConnectionCloseEvent.patch new file mode 100644 index 000000000..a23bda6c1 --- /dev/null +++ b/patches/api/0018-Add-reason-to-PlayerConnectionCloseEvent.patch @@ -0,0 +1,56 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Cryptite +Date: Tue, 22 Aug 2023 06:22:17 -0500 +Subject: [PATCH] Add reason to PlayerConnectionCloseEvent + + +diff --git a/src/main/java/com/destroystokyo/paper/event/player/PlayerConnectionCloseEvent.java b/src/main/java/com/destroystokyo/paper/event/player/PlayerConnectionCloseEvent.java +index 12c1c6fe9dc8dc5f5faf6dcf99f6857219ef22b8..42954466c13a926e735754949cc9d78fa1ad7b10 100644 +--- a/src/main/java/com/destroystokyo/paper/event/player/PlayerConnectionCloseEvent.java ++++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerConnectionCloseEvent.java +@@ -50,12 +50,18 @@ public class PlayerConnectionCloseEvent extends Event { + @NotNull private final UUID playerUniqueId; + @NotNull private final String playerName; + @NotNull private final InetAddress ipAddress; ++ @NotNull private final ConnectionCloseReason reason; + + public PlayerConnectionCloseEvent(@NotNull final UUID playerUniqueId, @NotNull final String playerName, @NotNull final InetAddress ipAddress, final boolean async) { ++ this(playerUniqueId, playerName, ipAddress, ConnectionCloseReason.NORMAL, async); ++ } ++ ++ public PlayerConnectionCloseEvent(@NotNull final UUID playerUniqueId, @NotNull final String playerName, @NotNull final InetAddress ipAddress, @NotNull ConnectionCloseReason reason, final boolean async) { + super(async); + this.playerUniqueId = playerUniqueId; + this.playerName = playerName; + this.ipAddress = ipAddress; ++ this.reason = reason; + } + + /** +@@ -92,4 +98,26 @@ public class PlayerConnectionCloseEvent extends Event { + public static HandlerList getHandlerList() { + return HANDLERS; + } ++ ++ /** ++ * Returns the reason for the closed connection. ++ */ ++ @NotNull ++ public ConnectionCloseReason getReason() { ++ return this.reason; ++ } ++ ++ public enum ConnectionCloseReason { ++ /** ++ * Player disconnected normally ++ */ ++ NORMAL, ++ ++ /** ++ * Player has invalid data for some reason. ++ *

++ * One example of this is a player logging into an unloaded world. ++ */ ++ INVALID_PLAYER_DATA, ++ } + } diff --git a/patches/server/0034-Add-reason-to-PlayerConnectionCloseEvent.patch b/patches/server/0034-Add-reason-to-PlayerConnectionCloseEvent.patch new file mode 100644 index 000000000..584e68b81 --- /dev/null +++ b/patches/server/0034-Add-reason-to-PlayerConnectionCloseEvent.patch @@ -0,0 +1,18 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Cryptite +Date: Tue, 22 Aug 2023 06:22:16 -0500 +Subject: [PATCH] Add reason to PlayerConnectionCloseEvent + + +diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +index 2ff578e4a953ffcf5176815ba8e3f06f73499989..f9a1b0e3be862cc00370c130621a07be5deebf0c 100644 +--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java ++++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +@@ -193,6 +193,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, + + this.connection.send(new ClientboundDisconnectPacket(ichatmutablecomponent)); + this.connection.disconnect(ichatmutablecomponent); ++ new com.destroystokyo.paper.event.player.PlayerConnectionCloseEvent(this.gameProfile.getId(), this.gameProfile.getName(), ((java.net.InetSocketAddress)this.connection.address).getAddress(), com.destroystokyo.paper.event.player.PlayerConnectionCloseEvent.ConnectionCloseReason.INVALID_PLAYER_DATA, false).callEvent(); // Slice + } + } +