From d59ae229701913bba5775f16cfaa61181020e5fe Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Fri, 16 Jun 2023 19:14:22 +0200 Subject: [PATCH] Deprecation, deprecated, ... --- .../bungee/players/BungeeOnlinePlayer.java | 45 +++++++------------ .../lib/core/mc_version/ProtocolVersion.java | 1 - .../lib/paper/players/PaperOnlinePlayer.java | 15 ------- .../lib/paper/util/ScoreboardUtil.java | 3 +- .../standalone/AbstractOnlinePlayer.java | 27 ----------- .../standalone/AbstractPlayerManager.java | 38 ++++++++++------ .../pandacube/lib/util/MinecraftVersion.java | 2 +- 7 files changed, 44 insertions(+), 87 deletions(-) diff --git a/pandalib-bungee/src/main/java/fr/pandacube/lib/bungee/players/BungeeOnlinePlayer.java b/pandalib-bungee/src/main/java/fr/pandacube/lib/bungee/players/BungeeOnlinePlayer.java index f34f65e..543c088 100644 --- a/pandalib-bungee/src/main/java/fr/pandacube/lib/bungee/players/BungeeOnlinePlayer.java +++ b/pandalib-bungee/src/main/java/fr/pandacube/lib/bungee/players/BungeeOnlinePlayer.java @@ -1,13 +1,13 @@ package fr.pandacube.lib.bungee.players; -import java.util.Locale; -import java.util.UUID; - +import fr.pandacube.lib.chat.Chat; +import fr.pandacube.lib.core.mc_version.ProtocolVersion; +import fr.pandacube.lib.players.standalone.AbstractOnlinePlayer; +import fr.pandacube.lib.reflect.Reflect; +import fr.pandacube.lib.util.MinecraftVersion; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufAllocator; -import net.kyori.adventure.identity.Identified; import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.ComponentLike; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.SkinConfiguration; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -18,10 +18,7 @@ import net.md_5.bungee.protocol.DefinedPacket; import net.md_5.bungee.protocol.packet.ClientSettings; import net.md_5.bungee.protocol.packet.PluginMessage; -import fr.pandacube.lib.chat.Chat; -import fr.pandacube.lib.players.standalone.AbstractOnlinePlayer; -import fr.pandacube.lib.reflect.Reflect; -import fr.pandacube.lib.util.MinecraftVersion; +import java.util.Locale; /** * Represents any online player on a Bungeecord proxy. @@ -55,11 +52,21 @@ public interface BungeeOnlinePlayer extends BungeeOffPlayer, AbstractOnlinePlaye /** * Gets the minecraft version of this player’s client. * @return the minecraft version of this player’s client. + * @deprecated use {@link #getProtocolVersion()} instead. */ + @Deprecated(forRemoval = true) default MinecraftVersion getMinecraftVersion() { return MinecraftVersion.getVersion(getBungeeProxiedPlayer().getPendingConnection().getVersion()); } + /** + * Gets the protocol version of this player’s client. + * @return the protocol version of this player’s client. + */ + default ProtocolVersion getProtocolVersion() { + return ProtocolVersion.ofProtocol(getBungeeProxiedPlayer().getPendingConnection().getVersion()); + } + @@ -91,26 +98,6 @@ public interface BungeeOnlinePlayer extends BungeeOffPlayer, AbstractOnlinePlaye getBungeeProxiedPlayer().sendMessage(Chat.toBungee(message)); } - @Override - default void sendMessage(ComponentLike message, UUID sender) { - getBungeeProxiedPlayer().sendMessage(sender, Chat.toBungee(message.asComponent())); - } - - @Override - default void sendMessage(Component message, Identified sender) { - getBungeeProxiedPlayer().sendMessage(sender == null ? null : sender.identity().uuid(), Chat.toBungee(message)); - } - - /** - * Display the provided message in the player’s chat, if they allows to display CHAT messages. - * @param message the message to send. - * @param sender the player causing the send of this message. Client side filtering may occur. May be null if we - * don’t want client filtering, but still consider the message as CHAT message. - */ - default void sendMessage(ComponentLike message, ProxiedPlayer sender) { - getBungeeProxiedPlayer().sendMessage(sender == null ? null : sender.getUniqueId(), Chat.toBungee(message.asComponent())); - } - @Override default void sendTitle(Component title, Component subtitle, int fadeIn, int stay, int fadeOut) { ProxyServer.getInstance().createTitle() diff --git a/pandalib-core/src/main/java/fr/pandacube/lib/core/mc_version/ProtocolVersion.java b/pandalib-core/src/main/java/fr/pandacube/lib/core/mc_version/ProtocolVersion.java index 7b3b351..7bcb72c 100644 --- a/pandalib-core/src/main/java/fr/pandacube/lib/core/mc_version/ProtocolVersion.java +++ b/pandalib-core/src/main/java/fr/pandacube/lib/core/mc_version/ProtocolVersion.java @@ -2,7 +2,6 @@ package fr.pandacube.lib.core.mc_version; import fr.pandacube.lib.core.json.Json; import fr.pandacube.lib.util.Log; -import fr.pandacube.lib.util.MinecraftVersion; import fr.pandacube.lib.util.StringUtil; import java.io.InputStream; diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/players/PaperOnlinePlayer.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/players/PaperOnlinePlayer.java index 54e3700..a8c38cf 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/players/PaperOnlinePlayer.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/players/PaperOnlinePlayer.java @@ -7,11 +7,7 @@ import fr.pandacube.lib.paper.players.PlayerNonPersistentConfig.Expiration; import fr.pandacube.lib.paper.reflect.wrapper.craftbukkit.CraftPlayer; import fr.pandacube.lib.players.standalone.AbstractOnlinePlayer; import fr.pandacube.lib.reflect.wrapper.ReflectWrapper; -import net.kyori.adventure.audience.MessageType; -import net.kyori.adventure.identity.Identified; -import net.kyori.adventure.identity.Identity; import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.ComponentLike; import net.kyori.adventure.title.Title; import net.kyori.adventure.title.Title.Times; import net.kyori.adventure.util.Ticks; @@ -24,7 +20,6 @@ import org.bukkit.inventory.MainHand; import org.bukkit.inventory.PlayerInventory; import java.util.Locale; -import java.util.UUID; /** * Represents any online player on a paper server. @@ -93,16 +88,6 @@ public interface PaperOnlinePlayer extends PaperOffPlayer, AbstractOnlinePlayer getBukkitPlayer().sendMessage(message); } - @Override - default void sendMessage(ComponentLike message, UUID sender) { - getBukkitPlayer().sendMessage(sender == null ? Identity.nil() : Identity.identity(sender), message, MessageType.CHAT); - } - - @Override - default void sendMessage(Component message, Identified sender) { - getBukkitPlayer().sendMessage(sender == null ? Identity.nil() : sender.identity(), message, MessageType.CHAT); - } - @Override default void sendTitle(Component title, Component subtitle, int fadeIn, int stay, int fadeOut) { getBukkitPlayer().showTitle(Title.title(title, subtitle, Times.times(Ticks.duration(fadeIn), Ticks.duration(stay), Ticks.duration(fadeOut)))); diff --git a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/ScoreboardUtil.java b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/ScoreboardUtil.java index 5b22668..86f36d0 100644 --- a/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/ScoreboardUtil.java +++ b/pandalib-paper/src/main/java/fr/pandacube/lib/paper/util/ScoreboardUtil.java @@ -50,7 +50,8 @@ public class ScoreboardUtil { obj.setDisplaySlot(DisplaySlot.SIDEBAR); } } - + + @SuppressWarnings("deprecation") ChatColor[] colors = ChatColor.values(); /* diff --git a/pandalib-players/src/main/java/fr/pandacube/lib/players/standalone/AbstractOnlinePlayer.java b/pandalib-players/src/main/java/fr/pandacube/lib/players/standalone/AbstractOnlinePlayer.java index c06eb5e..2370b16 100644 --- a/pandalib-players/src/main/java/fr/pandacube/lib/players/standalone/AbstractOnlinePlayer.java +++ b/pandalib-players/src/main/java/fr/pandacube/lib/players/standalone/AbstractOnlinePlayer.java @@ -1,13 +1,10 @@ package fr.pandacube.lib.players.standalone; import fr.pandacube.lib.chat.ChatStatic; -import net.kyori.adventure.identity.Identified; -import net.kyori.adventure.identity.Identity; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.ComponentLike; import java.util.Locale; -import java.util.UUID; /** * Represents any online player. @@ -87,30 +84,6 @@ public interface AbstractOnlinePlayer extends AbstractOffPlayer { default void sendMessage(ComponentLike message) { sendMessage(message.asComponent()); } - - /** - * Display the provided message in the player’s chat, if they allows to display CHAT messages. - * @param message the message to display. - * @param sender the player causing the send of this message. Client side filtering may occur. - * May be null if we don’t want client filtering, but still consider the message as CHAT message. - * @implNote implementation of this method should not filter the send of the message, based on - * the sender. This parameter is only there to be transmitted to the client, so client side filtering can - * be processed. - */ - void sendMessage(Component message, Identified sender); - - /** - * Display the provided message in the player’s chat, if they allows to display CHAT messages. - * @param message the message to display - * @param sender the player causing the send of this message. Client side filtering may occur. - * May be null if we don’t want client filtering, but still consider the message as CHAT message. - * @implNote implementation of this method should not filter the send of the message, based on - * the sender. This parameter is only there to be transmitted to the client, so client side filtering can - * be processed. - */ - default void sendMessage(ComponentLike message, UUID sender) { - sendMessage(message.asComponent(), () -> sender == null ? Identity.nil() : Identity.identity(sender)); - } /** * Display the provided message in the player’s chat, if the chat is activated, prepended with the server prefix. diff --git a/pandalib-players/src/main/java/fr/pandacube/lib/players/standalone/AbstractPlayerManager.java b/pandalib-players/src/main/java/fr/pandacube/lib/players/standalone/AbstractPlayerManager.java index 84a8ca1..b835d47 100644 --- a/pandalib-players/src/main/java/fr/pandacube/lib/players/standalone/AbstractPlayerManager.java +++ b/pandalib-players/src/main/java/fr/pandacube/lib/players/standalone/AbstractPlayerManager.java @@ -184,37 +184,49 @@ public abstract class AbstractPlayerManager