58 lines
2.3 KiB
Diff
58 lines
2.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Cryptite <cryptite@gmail.com>
|
|
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 d0fb13adc140f1ca74d0c3448f92baa60684f3e2..3c69210c2d665794fb77b6ff23d632a02e626875 100644
|
|
--- a/src/main/java/com/destroystokyo/paper/event/player/PlayerConnectionCloseEvent.java
|
|
+++ b/src/main/java/com/destroystokyo/paper/event/player/PlayerConnectionCloseEvent.java
|
|
@@ -42,13 +42,19 @@ 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;
|
|
|
|
@ApiStatus.Internal
|
|
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;
|
|
}
|
|
|
|
/**
|
|
@@ -85,4 +91,26 @@ public class PlayerConnectionCloseEvent extends Event {
|
|
public static HandlerList getHandlerList() {
|
|
return HANDLER_LIST;
|
|
}
|
|
+
|
|
+ /**
|
|
+ * 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.
|
|
+ * <p>
|
|
+ * One example of this is a player logging into an unloaded world.
|
|
+ */
|
|
+ INVALID_PLAYER_DATA,
|
|
+ }
|
|
}
|