geforkt von Mirrors/Velocity
Rebase onto feature/adventure-pointers
Dieser Commit ist enthalten in:
Ursprung
9491046935
Commit
f59516165f
@ -14,12 +14,13 @@ import net.kyori.adventure.audience.MessageType;
|
||||
import net.kyori.adventure.identity.Identified;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.permission.PermissionChecker;
|
||||
import net.kyori.adventure.pointer.Pointers;
|
||||
import net.kyori.adventure.pointer.Pointer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.legacytext3.LegacyText3ComponentSerializer;
|
||||
import net.kyori.adventure.util.TriState;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Represents something that can be used to run a {@link Command}.
|
||||
@ -43,8 +44,12 @@ public interface CommandSource extends Audience, PermissionSubject, PermissionCh
|
||||
}
|
||||
|
||||
@Override
|
||||
default @NotNull Pointers pointers() {
|
||||
return Pointers.builder().withStatic(PermissionChecker.POINTER, this).build();
|
||||
@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);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -28,7 +28,6 @@ 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;
|
||||
@ -304,13 +303,4 @@ public interface Player extends CommandSource, Identified, InboundConnection,
|
||||
return HoverEvent.showEntity(op.apply(HoverEvent.ShowEntity.of(this, getUniqueId(),
|
||||
Component.text(getUsername()))));
|
||||
}
|
||||
|
||||
@Override
|
||||
default @NotNull Pointers pointers() {
|
||||
return CommandSource.super.pointers().toBuilder()
|
||||
.withDynamic(Identity.NAME, this::getUsername)
|
||||
.withDynamic(Identity.DISPLAY_NAME, this::asComponent)
|
||||
.withDynamic(Identity.UUID, this::getUniqueId)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
@ -285,8 +285,8 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
||||
return Optional.of((T) this.getUniqueId());
|
||||
} else if (pointer == Identity.NAME) {
|
||||
return Optional.of((T) this.getGameProfile().getName());
|
||||
} else if (pointer == PermissionChecker.POINTER) {
|
||||
return Optional.of((T) this.permissionChecker);
|
||||
} else if (pointer == Identity.DISPLAY_NAME) {
|
||||
return Optional.of((T) asComponent());
|
||||
}
|
||||
return Player.super.get(pointer);
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren