From 2262681351fc1f30c647dd3134264ba1dff4881c Mon Sep 17 00:00:00 2001 From: _tomcraft <936063+tomcraft@users.noreply.github.com> Date: Wed, 13 Jul 2022 10:24:14 +0200 Subject: [PATCH] Reference command permission to filter root suggestions (/via) (#3018) --- bukkit/src/main/resources/plugin.yml | 1 + .../viaversion/viaversion/bungee/commands/BungeeCommand.java | 2 +- .../viaversion/velocity/command/VelocityCommandHandler.java | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/bukkit/src/main/resources/plugin.yml b/bukkit/src/main/resources/plugin.yml index 744f113db..507ceda7b 100644 --- a/bukkit/src/main/resources/plugin.yml +++ b/bukkit/src/main/resources/plugin.yml @@ -8,5 +8,6 @@ loadbefore: [ProtocolLib, ProxyPipe, SpigotLib, SkinRestorer] softdepend: [ProtocolSupport, PacketListenerApi] commands: viaversion: + permission: viaversion.admin # The permission is also referenced here to filter root suggestions (/via) description: Shows ViaVersion Version and more. aliases: [viaver, vvbukkit] \ No newline at end of file diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/commands/BungeeCommand.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/commands/BungeeCommand.java index bd3be5e4d..c208bd8a0 100644 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/commands/BungeeCommand.java +++ b/bungee/src/main/java/com/viaversion/viaversion/bungee/commands/BungeeCommand.java @@ -25,7 +25,7 @@ public class BungeeCommand extends Command implements TabExecutor { private final BungeeCommandHandler handler; public BungeeCommand(BungeeCommandHandler handler) { - super("viaversion", "", "viaver", "vvbungee"); // The CommandHandler will handle the permission + super("viaversion", "viaversion.admin", "viaver", "vvbungee"); // The permission is also referenced here to filter root suggestions (/via) this.handler = handler; } diff --git a/velocity/src/main/java/com/viaversion/viaversion/velocity/command/VelocityCommandHandler.java b/velocity/src/main/java/com/viaversion/viaversion/velocity/command/VelocityCommandHandler.java index 096d8631d..43f3e2912 100644 --- a/velocity/src/main/java/com/viaversion/viaversion/velocity/command/VelocityCommandHandler.java +++ b/velocity/src/main/java/com/viaversion/viaversion/velocity/command/VelocityCommandHandler.java @@ -41,4 +41,9 @@ public class VelocityCommandHandler extends ViaCommandHandler implements SimpleC public List suggest(Invocation invocation) { return onTabComplete(new VelocityCommandSender(invocation.source()), invocation.arguments()); } + + @Override + public boolean hasPermission(Invocation invocation) { + return invocation.source().hasPermission("viaversion.admin"); // The permission is also referenced here to filter root suggestions (/via) + } }