Paper/patches/api/0468-Add-listing-API-for-PlayerProfile.patch
2024-04-07 01:58:04 +02:00

81 lines
3.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Flo0 <flo.roma@web.de>
Date: Sat, 6 Apr 2024 23:15:08 +0200
Subject: [PATCH] Add listing API for PlayerProfile
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
index c6cb4f17469a8f2e60dd3e28d41402851ce5fb21..8d35bb590facb83487729fe5cca9e8450bbac9d2 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -2054,6 +2054,69 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
boolean listPlayer(@NotNull Player other);
// Paper end
+ // Paper start - Add Listing API for PlayerProfile
+ /**
+ * Lists the {@code profile} in the tablist.
+ * Burden of tracking the profile is on the caller.
+ * Using profiles of online players is an invalid operation.
+ * Use {@link #listPlayer(Player)} instead.
+ *
+ * @param profile The {@link com.destroystokyo.paper.profile.PlayerProfile} to list.
+ * @param latency The latency of the profile in milliseconds.
+ * @param gameMode The game mode of the profile.
+ * @param displayName The display name of the profile.
+ */
+ void listProfile(@NotNull com.destroystokyo.paper.profile.PlayerProfile profile, int latency, @NotNull GameMode gameMode, @Nullable net.kyori.adventure.text.Component displayName);
+
+ /**
+ * Lists the {@code profile} in the tablist.
+ * Burden of tracking the profile is on the caller.
+ * Using profiles of online players is an invalid operation.
+ * Use {@link #listPlayer(Player)} instead.
+ *
+ * @param profile The {@link com.destroystokyo.paper.profile.PlayerProfile} to list.
+ */
+ default void listProfile(@NotNull com.destroystokyo.paper.profile.PlayerProfile profile) {
+ listProfile(profile, 0, GameMode.SURVIVAL, null);
+ }
+
+ /**
+ * Updates the latency of the {@code profile} in the tablist.
+ * If the {@code profile} is not listed, this method has no effect.
+ *
+ * @param profile The {@link com.destroystokyo.paper.profile.PlayerProfile} to update in the tablist.
+ * @param latency The new latency of the profile in milliseconds.
+ */
+ void updateListedProfileLatency(@NotNull com.destroystokyo.paper.profile.PlayerProfile profile, int latency);
+
+ /**
+ * Updates the game mode of the {@code profile} in the tablist.
+ * If the {@code profile} is not listed, this method has no effect.
+ *
+ * @param profile The {@link com.destroystokyo.paper.profile.PlayerProfile} to update in the tablist.
+ * @param gameMode The new game mode of the profile.
+ */
+ void updateListedProfileGameMode(@NotNull com.destroystokyo.paper.profile.PlayerProfile profile, @NotNull GameMode gameMode);
+
+ /**
+ * Updates the display name of the {@code profile} in the tablist.
+ * If the {@code profile} is not listed, this method has no effect.
+ *
+ * @param profile The {@link com.destroystokyo.paper.profile.PlayerProfile} to update in the tablist.
+ * @param displayName The new display name of the profile.
+ */
+ void updateListedProfileDisplayName(@NotNull com.destroystokyo.paper.profile.PlayerProfile profile, @Nullable net.kyori.adventure.text.Component displayName);
+
+ /**
+ * Unlists the {@code profile} from the tablist.
+ * Using profiles of online players is an invalid operation.
+ * Use {@link #unlistPlayer(Player)} instead.
+ *
+ * @param profile The {@link com.destroystokyo.paper.profile.PlayerProfile} to de-list.
+ */
+ void unlistProfile(@NotNull com.destroystokyo.paper.profile.PlayerProfile profile);
+ // Paper end - Add Listing API for PlayerProfile
+
/**
* Checks to see if this player is currently flying or not.
*