aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0418-Add-OfflinePlayer-isConnected.patch
diff options
context:
space:
mode:
authorMalfrador <[email protected]>2024-07-15 12:31:41 +0200
committerGitHub <[email protected]>2024-07-15 12:31:41 +0200
commit9fd5b3cfbd40b2847dec14f53c1b3b68aed46f12 (patch)
tree96914d111f50e21fa04bde89a96d9237e581675b /patches/api/0418-Add-OfflinePlayer-isConnected.patch
parent99ae7bbc9760e02fbd5388ad3890258203ee6d5a (diff)
downloadPaper-9fd5b3cfbd40b2847dec14f53c1b3b68aed46f12.tar.gz
Paper-9fd5b3cfbd40b2847dec14f53c1b3b68aed46f12.zip
Add AttributeModifier constructor without EquipmentSlotGroup (#11079)
Diffstat (limited to 'patches/api/0418-Add-OfflinePlayer-isConnected.patch')
-rw-r--r--patches/api/0418-Add-OfflinePlayer-isConnected.patch38
1 files changed, 38 insertions, 0 deletions
diff --git a/patches/api/0418-Add-OfflinePlayer-isConnected.patch b/patches/api/0418-Add-OfflinePlayer-isConnected.patch
new file mode 100644
index 0000000000..08e2f91095
--- /dev/null
+++ b/patches/api/0418-Add-OfflinePlayer-isConnected.patch
@@ -0,0 +1,38 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Aeltumn <[email protected]>
+Date: Thu, 24 Aug 2023 13:05:07 +0200
+Subject: [PATCH] Add OfflinePlayer#isConnected
+
+This adds an alternative to OfflinePlayer#isOnline that returns true only if the same instance of the player is still online. This is generally more useful than isOnline as it allows you to determine if you have an instance of a Player that still exists. If a player relogs an old Player instance becomes unlinked leading to e.g. messages sent to the old player no longer arriving despite isOnline returning true. Checking against isConnected is more useful there to discard invalid instances.
+
+diff --git a/src/main/java/org/bukkit/OfflinePlayer.java b/src/main/java/org/bukkit/OfflinePlayer.java
+index 299d1cc510d24541c6bb47d02db0b6a86fb1d0eb..3993fecec5b4c2bbd77e175a168afcad571ce4d1 100644
+--- a/src/main/java/org/bukkit/OfflinePlayer.java
++++ b/src/main/java/org/bukkit/OfflinePlayer.java
+@@ -24,10 +24,26 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio
+ /**
+ * Checks if this player is currently online
+ *
++ * It should be noted that this will return true if any instance of this player is
++ * online! This instance may have disconnected. If you wish to check if this specific
++ * instance of the player is still online, see {@link OfflinePlayer#isConnected()}.
++ *
+ * @return true if they are online
+ */
+ public boolean isOnline();
+
++ // Paper start
++ /**
++ * Checks whether the connection to this player is still valid. This will return
++ * true as long as this specific instance of the player is still connected. This
++ * will return false after this instance has disconnected, even if the same player
++ * has reconnected since.
++ *
++ * @return true if this player instance is connected
++ */
++ public boolean isConnected();
++ // Paper end
++
+ /**
+ * Returns the name of this player
+ * <p>