Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-16 21:10:30 +01:00
Cache permission pointers
Dieser Commit ist enthalten in:
Ursprung
4003666c27
Commit
8356b812c3
@ -14,12 +14,10 @@ import net.kyori.adventure.audience.MessageType;
|
|||||||
import net.kyori.adventure.identity.Identified;
|
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.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;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents something that can be used to run a {@link Command}.
|
* Represents something that can be used to run a {@link Command}.
|
||||||
@ -42,11 +40,6 @@ public interface CommandSource extends Audience, PermissionSubject {
|
|||||||
this.sendMessage(LegacyText3ComponentSerializer.get().serialize(message));
|
this.sendMessage(LegacyText3ComponentSerializer.get().serialize(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
default @NotNull Pointers pointers() {
|
|
||||||
return Pointers.builder().withStatic(PermissionChecker.POINTER, getPermissionChecker()).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the permission checker for the invoker.
|
* Gets the permission checker for the invoker.
|
||||||
*
|
*
|
||||||
|
@ -94,6 +94,7 @@ import java.util.concurrent.ThreadLocalRandom;
|
|||||||
import net.kyori.adventure.audience.MessageType;
|
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.pointer.Pointers;
|
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;
|
||||||
@ -148,6 +149,7 @@ public class ConnectedPlayer implements MinecraftConnectionAssociation, Player {
|
|||||||
.withDynamic(Identity.UUID, this::getUniqueId)
|
.withDynamic(Identity.UUID, this::getUniqueId)
|
||||||
.withDynamic(Identity.NAME, this::getUsername)
|
.withDynamic(Identity.NAME, this::getUsername)
|
||||||
.withDynamic(Identity.DISPLAY_NAME, this::getDisplayName)
|
.withDynamic(Identity.DISPLAY_NAME, this::getDisplayName)
|
||||||
|
.withStatic(PermissionChecker.POINTER, getPermissionChecker())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
ConnectedPlayer(VelocityServer server, GameProfile profile, MinecraftConnection connection,
|
ConnectedPlayer(VelocityServer server, GameProfile profile, MinecraftConnection connection,
|
||||||
|
@ -26,6 +26,8 @@ import com.velocitypowered.api.proxy.ConsoleCommandSource;
|
|||||||
import com.velocitypowered.proxy.VelocityServer;
|
import com.velocitypowered.proxy.VelocityServer;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.kyori.adventure.identity.Identity;
|
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.Component;
|
||||||
import net.kyori.text.TextComponent;
|
import net.kyori.text.TextComponent;
|
||||||
import net.kyori.text.format.TextColor;
|
import net.kyori.text.format.TextColor;
|
||||||
@ -35,6 +37,7 @@ import org.apache.logging.log4j.LogManager;
|
|||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.apache.logging.log4j.io.IoBuilder;
|
import org.apache.logging.log4j.io.IoBuilder;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jline.reader.Candidate;
|
import org.jline.reader.Candidate;
|
||||||
import org.jline.reader.LineReader;
|
import org.jline.reader.LineReader;
|
||||||
import org.jline.reader.LineReaderBuilder;
|
import org.jline.reader.LineReaderBuilder;
|
||||||
@ -45,6 +48,8 @@ public final class VelocityConsole extends SimpleTerminalConsole implements Cons
|
|||||||
|
|
||||||
private final VelocityServer server;
|
private final VelocityServer server;
|
||||||
private PermissionFunction permissionFunction = ALWAYS_TRUE;
|
private PermissionFunction permissionFunction = ALWAYS_TRUE;
|
||||||
|
private final @NotNull Pointers pointers = ConsoleCommandSource.super.pointers().toBuilder()
|
||||||
|
.withDynamic(PermissionChecker.POINTER, this::getPermissionChecker).build();
|
||||||
|
|
||||||
public VelocityConsole(VelocityServer server) {
|
public VelocityConsole(VelocityServer server) {
|
||||||
this.server = server;
|
this.server = server;
|
||||||
@ -131,4 +136,9 @@ public final class VelocityConsole extends SimpleTerminalConsole implements Cons
|
|||||||
protected void shutdown() {
|
protected void shutdown() {
|
||||||
this.server.shutdown(true);
|
this.server.shutdown(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull Pointers pointers() {
|
||||||
|
return pointers;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren