Deprecation, deprecated, ...
This commit is contained in:
parent
e6fc31e5ca
commit
d59ae22970
@ -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()
|
||||
|
@ -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;
|
||||
|
@ -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))));
|
||||
|
@ -51,6 +51,7 @@ public class ScoreboardUtil {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
ChatColor[] colors = ChatColor.values();
|
||||
|
||||
/*
|
||||
|
@ -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.
|
||||
@ -88,30 +85,6 @@ public interface AbstractOnlinePlayer extends AbstractOffPlayer {
|
||||
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.
|
||||
* @param message the message to display
|
||||
|
@ -184,33 +184,25 @@ public abstract class AbstractPlayerManager<OP extends AbstractOnlinePlayer, OF
|
||||
|
||||
|
||||
/**
|
||||
* Broadcast a message to some or all players, and eventually to the console.
|
||||
* Broadcast a SYSTEM message to some or all players, and eventually to the console.
|
||||
*
|
||||
* @param message the message to send.
|
||||
* @param prefix if the server prefix will be prepended to the message.
|
||||
* @param console if the message must be displayed in the console.
|
||||
* @param permission if not null, the message is only sent to player with this permission.
|
||||
* @param sourcePlayer specifiy the eventual player that is the source of the message.
|
||||
* If null, the message will be sent as a SYSTEM chat message.
|
||||
* If not null, the message will be sent as a CHAT message, and will not be sent
|
||||
* to players ignoring the provided player (if implemented).
|
||||
* @throws IllegalArgumentException if message is null.
|
||||
* @implSpec subclasses may override this method, for instance to restrict the players being able to see the message
|
||||
* (like /ignored players).
|
||||
*/
|
||||
public void broadcastMessage(ComponentLike message, boolean prefix, boolean console, String permission, UUID sourcePlayer) {
|
||||
public void broadcastMessage(ComponentLike message, boolean prefix, boolean console, String permission) {
|
||||
Objects.requireNonNull(message, "message cannot be null");
|
||||
|
||||
if (prefix)
|
||||
message = ChatStatic.prefixedAndColored(message.asComponent());
|
||||
|
||||
for (OP op : getAll()) {
|
||||
if (permission != null && !(op.hasPermission(permission))) continue;
|
||||
|
||||
if (sourcePlayer != null)
|
||||
op.sendMessage(message, sourcePlayer); // CHAT message with UUID
|
||||
else
|
||||
op.sendMessage(message); // SYSTEM message
|
||||
if (permission != null && !(op.hasPermission(permission)))
|
||||
continue;
|
||||
op.sendMessage(message);
|
||||
}
|
||||
if (console)
|
||||
sendMessageToConsole(message.asComponent());
|
||||
@ -218,6 +210,26 @@ public abstract class AbstractPlayerManager<OP extends AbstractOnlinePlayer, OF
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Broadcast a message to some or all players, and eventually to the console.
|
||||
*
|
||||
* @param message the message to send.
|
||||
* @param prefix if the server prefix will be prepended to the message.
|
||||
* @param console if the message must be displayed in the console.
|
||||
* @param permission if not null, the message is only sent to player with this permission.
|
||||
* @param sourcePlayer specify the eventual player that is the source of the message. Default implementation of this
|
||||
* method does not use this parameter due to the Minecraft client not handling unsigned CHAT
|
||||
* messages.
|
||||
* @throws IllegalArgumentException if message is null.
|
||||
* @implSpec subclasses may override this method, for instance to restrict the players being able to see the message
|
||||
* (like /ignored players).
|
||||
*/
|
||||
public void broadcastMessage(ComponentLike message, boolean prefix, boolean console, String permission, UUID sourcePlayer) {
|
||||
broadcastMessage(message, prefix, console, permission);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -17,7 +17,7 @@ import java.util.Set;
|
||||
* Note that this enum uses one value to represent every Minecraft version using the same protocol version number.
|
||||
* @deprecated This class may not be updated. Use the class ProtocolVersion in pandalib-core module instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@Deprecated(forRemoval = true)
|
||||
public enum MinecraftVersion {
|
||||
/** Minecraft versions 1.7.2 to 1.7.5, protocol version 4. */
|
||||
v1_7_2_to_1_7_5(4, "1.7.2", "1.7.3", "1.7.4", "1.7.5"),
|
||||
|
Loading…
Reference in New Issue
Block a user