3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-16 21:10:30 +01:00

Move #pointers to Player

It uses fully API methods so it makes sense to me to use it in Player, open to criticism though
Dieser Commit ist enthalten in:
lexikiq 2021-06-11 21:33:15 -04:00
Ursprung db7e3262a6
Commit 29b409b9f1
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: AE6C11E94FDBB116
2 geänderte Dateien mit 10 neuen und 11 gelöschten Zeilen

Datei anzeigen

@ -28,6 +28,7 @@ import net.kyori.adventure.identity.Identified;
import net.kyori.adventure.identity.Identity; import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.key.Key; import net.kyori.adventure.key.Key;
import net.kyori.adventure.key.Keyed; import net.kyori.adventure.key.Keyed;
import net.kyori.adventure.pointer.Pointers;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.ComponentLike; import net.kyori.adventure.text.ComponentLike;
import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.event.ClickEvent;
@ -285,6 +286,15 @@ public interface Player extends CommandSource, Identified, InboundConnection,
@Override @Override
boolean sendPluginMessage(ChannelIdentifier identifier, byte[] data); 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 @Override
default @NotNull Key key() { default @NotNull Key key() {
return Key.key("player"); return Key.key("player");

Datei anzeigen

@ -95,7 +95,6 @@ import net.kyori.adventure.audience.MessageType;
import net.kyori.adventure.bossbar.BossBar; import net.kyori.adventure.bossbar.BossBar;
import net.kyori.adventure.identity.Identity; import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.permission.PermissionChecker; import net.kyori.adventure.permission.PermissionChecker;
import net.kyori.adventure.pointer.Pointers;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TranslatableComponent; import net.kyori.adventure.text.TranslatableComponent;
import net.kyori.adventure.text.format.NamedTextColor; 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.MonotonicNonNull;
import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable; import org.checkerframework.checker.nullness.qual.Nullable;
import org.jetbrains.annotations.NotNull;
public class ConnectedPlayer implements MinecraftConnectionAssociation, Player { public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
@ -279,15 +277,6 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
return connection.getProtocolVersion(); 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 @Override
public void sendMessage(net.kyori.text.Component component, MessagePosition position) { public void sendMessage(net.kyori.text.Component component, MessagePosition position) {
Preconditions.checkNotNull(component, "component"); Preconditions.checkNotNull(component, "component");