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

Switch to #pointers

Ensures that Pointered#getOrDefault[From] works
Dieser Commit ist enthalten in:
lexikiq 2021-06-11 21:12:44 -04:00
Ursprung 069796a2f2
Commit 3c4312056b
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: AE6C11E94FDBB116
2 geänderte Dateien mit 11 neuen und 16 gelöschten Zeilen

Datei anzeigen

@ -16,6 +16,7 @@ import net.kyori.adventure.identity.Identified;
import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.permission.PermissionChecker;
import net.kyori.adventure.pointer.Pointer;
import net.kyori.adventure.pointer.Pointers;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.legacytext3.LegacyText3ComponentSerializer;
import net.kyori.adventure.util.TriState;
@ -44,12 +45,8 @@ public interface CommandSource extends Audience, PermissionSubject, PermissionCh
}
@Override
@SuppressWarnings("unchecked") // safe casts
default @NotNull <T> Optional<T> get(final @NotNull Pointer<T> pointer) {
if (pointer == PermissionChecker.POINTER) {
return Optional.of((T) this);
}
return Audience.super.get(pointer);
default @NotNull Pointers pointers() {
return Pointers.builder().withStatic(PermissionChecker.POINTER, this).build();
}
@Override

Datei anzeigen

@ -96,6 +96,7 @@ import net.kyori.adventure.bossbar.BossBar;
import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.permission.PermissionChecker;
import net.kyori.adventure.pointer.Pointer;
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,6 +109,7 @@ 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,16 +281,12 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
}
@Override
@SuppressWarnings("unchecked") // safe casts
public <T> Optional<T> get(final Pointer<T> pointer) {
if (pointer == Identity.UUID) {
return Optional.of((T) this.getUniqueId());
} else if (pointer == Identity.NAME) {
return Optional.of((T) this.getGameProfile().getName());
} else if (pointer == Identity.DISPLAY_NAME) {
return Optional.of((T) asComponent());
}
return Player.super.get(pointer);
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