3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-15 19:10:09 +01:00
Paper/patches/api/0419-Add-OfflinePlayer-isConnected.patch
Bjarne Koll e1c0033552
Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
2b4b6d14 PR-1023: Convert InventoryView to interface

CraftBukkit Changes:
68603b1c1 Use expanded interaction ranges for traced interact events
eae9f760c PR-1414: Convert InventoryView to interface
ee9eafe67 Fix Implementation for DamageSource#isIndirect for internal custom causing entity
2024-06-16 17:23:42 +02:00

39 Zeilen
2.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aeltumn <daniel@goossens.ch>
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>