diff --git a/patches/api/0468-Add-listing-API-for-PlayerProfile.patch b/patches/api/0468-Add-listing-API-for-PlayerProfile.patch new file mode 100644 index 0000000000..2db70f0187 --- /dev/null +++ b/patches/api/0468-Add-listing-API-for-PlayerProfile.patch @@ -0,0 +1,80 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Flo0 +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. + * diff --git a/patches/server/1055-Add-listing-API-for-PlayerProfile.patch b/patches/server/1055-Add-listing-API-for-PlayerProfile.patch new file mode 100644 index 0000000000..865ab5d6fb --- /dev/null +++ b/patches/server/1055-Add-listing-API-for-PlayerProfile.patch @@ -0,0 +1,133 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Flo0 +Date: Sat, 6 Apr 2024 23:15:24 +0200 +Subject: [PATCH] Add listing API for PlayerProfile + + +diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java +index 56eddd28429cf42c02d88b8bf79f8b616fa45289..ba3dde833e073a9979af5b3554f669b9ec0ccf7e 100644 +--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java ++++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java +@@ -16,6 +16,7 @@ import net.minecraft.network.protocol.Packet; + import net.minecraft.server.level.ServerPlayer; + import net.minecraft.world.level.GameType; + ++ + public class ClientboundPlayerInfoUpdatePacket implements Packet { + private final EnumSet actions; + private final List entries; +@@ -68,6 +69,35 @@ public class ClientboundPlayerInfoUpdatePacket implements Packet enumSet = EnumSet.of( ++ ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, ++ ClientboundPlayerInfoUpdatePacket.Action.UPDATE_LISTED, ++ ClientboundPlayerInfoUpdatePacket.Action.UPDATE_LATENCY, ++ ClientboundPlayerInfoUpdatePacket.Action.UPDATE_GAME_MODE ++ ); ++ ++ if(displayName != null) { ++ enumSet.add(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_DISPLAY_NAME); ++ } ++ ++ UUID profileId = profile.getId(); ++ return new ClientboundPlayerInfoUpdatePacket(enumSet, new ClientboundPlayerInfoUpdatePacket.Entry(profileId, profile, true, latency, gameMode, displayName, null)); ++ } ++ public static ClientboundPlayerInfoUpdatePacket updateLatency(UUID playerInfoId, int latency) { ++ EnumSet enumSet = EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_LATENCY); ++ return new ClientboundPlayerInfoUpdatePacket(enumSet, new ClientboundPlayerInfoUpdatePacket.Entry(playerInfoId, true, latency, GameType.DEFAULT_MODE, null)); ++ } ++ public static ClientboundPlayerInfoUpdatePacket updateGameMode(UUID playerInfoId, GameType gameMode) { ++ EnumSet enumSet = EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_GAME_MODE); ++ return new ClientboundPlayerInfoUpdatePacket(enumSet, new ClientboundPlayerInfoUpdatePacket.Entry(playerInfoId, true, 0, gameMode, null)); ++ } ++ public static ClientboundPlayerInfoUpdatePacket updateDisplayName(UUID playerInfoId, Component displayName) { ++ EnumSet enumSet = EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_DISPLAY_NAME); ++ return new ClientboundPlayerInfoUpdatePacket(enumSet, new ClientboundPlayerInfoUpdatePacket.Entry(playerInfoId, true, 0, GameType.DEFAULT_MODE, displayName)); ++ } ++ // Paper end - Add Listing API for PlayerProfile + + public ClientboundPlayerInfoUpdatePacket(FriendlyByteBuf buf) { + this.actions = buf.readEnumSet(ClientboundPlayerInfoUpdatePacket.Action.class); +@@ -188,6 +218,11 @@ public class ClientboundPlayerInfoUpdatePacket implements Packet serialize() { + Map result = new LinkedHashMap();