From 29b409b9f19f2d012931f8874f4831f2361df8f3 Mon Sep 17 00:00:00 2001 From: lexikiq Date: Fri, 11 Jun 2021 21:33:15 -0400 Subject: [PATCH] Move #pointers to Player It uses fully API methods so it makes sense to me to use it in Player, open to criticism though --- .../java/com/velocitypowered/api/proxy/Player.java | 10 ++++++++++ .../proxy/connection/client/ConnectedPlayer.java | 11 ----------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/api/src/main/java/com/velocitypowered/api/proxy/Player.java b/api/src/main/java/com/velocitypowered/api/proxy/Player.java index a06db7ba0..f96807eed 100644 --- a/api/src/main/java/com/velocitypowered/api/proxy/Player.java +++ b/api/src/main/java/com/velocitypowered/api/proxy/Player.java @@ -28,6 +28,7 @@ import net.kyori.adventure.identity.Identified; import net.kyori.adventure.identity.Identity; import net.kyori.adventure.key.Key; import net.kyori.adventure.key.Keyed; +import net.kyori.adventure.pointer.Pointers; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.ComponentLike; import net.kyori.adventure.text.event.ClickEvent; @@ -285,6 +286,15 @@ public interface Player extends CommandSource, Identified, InboundConnection, @Override boolean sendPluginMessage(ChannelIdentifier identifier, byte[] data); + @Override + default @NotNull Pointers pointers() { + return CommandSource.super.pointers().toBuilder() + .withDynamic(Identity.UUID, this::getUniqueId) + .withDynamic(Identity.NAME, this::getUsername) + .withDynamic(Identity.DISPLAY_NAME, this::asComponent) + .build(); + } + @Override default @NotNull Key key() { return Key.key("player"); diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java index 1f0540b53..e95f3ae8d 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java @@ -95,7 +95,6 @@ import net.kyori.adventure.audience.MessageType; import net.kyori.adventure.bossbar.BossBar; import net.kyori.adventure.identity.Identity; import net.kyori.adventure.permission.PermissionChecker; -import net.kyori.adventure.pointer.Pointers; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TranslatableComponent; import net.kyori.adventure.text.format.NamedTextColor; @@ -108,7 +107,6 @@ import org.apache.logging.log4j.Logger; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; -import org.jetbrains.annotations.NotNull; public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { @@ -279,15 +277,6 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { return connection.getProtocolVersion(); } - @Override - public @NotNull Pointers pointers() { - return Player.super.pointers().toBuilder() - .withDynamic(Identity.UUID, this::getUniqueId) - .withDynamic(Identity.NAME, this::getUsername) - .withDynamic(Identity.DISPLAY_NAME, this::asComponent) - .build(); - } - @Override public void sendMessage(net.kyori.text.Component component, MessagePosition position) { Preconditions.checkNotNull(component, "component");