3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-17 05:20:14 +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.identity.Identity;
import net.kyori.adventure.permission.PermissionChecker; import net.kyori.adventure.permission.PermissionChecker;
import net.kyori.adventure.pointer.Pointer; import net.kyori.adventure.pointer.Pointer;
import net.kyori.adventure.pointer.Pointers;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.legacytext3.LegacyText3ComponentSerializer; import net.kyori.adventure.text.serializer.legacytext3.LegacyText3ComponentSerializer;
import net.kyori.adventure.util.TriState; import net.kyori.adventure.util.TriState;
@ -44,12 +45,8 @@ public interface CommandSource extends Audience, PermissionSubject, PermissionCh
} }
@Override @Override
@SuppressWarnings("unchecked") // safe casts default @NotNull Pointers pointers() {
default @NotNull <T> Optional<T> get(final @NotNull Pointer<T> pointer) { return Pointers.builder().withStatic(PermissionChecker.POINTER, this).build();
if (pointer == PermissionChecker.POINTER) {
return Optional.of((T) this);
}
return Audience.super.get(pointer);
} }
@Override @Override

Datei anzeigen

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