Reference command permission to filter root suggestions (/via<tab>) (#3018)

This commit is contained in:
_tomcraft 2022-07-13 10:24:14 +02:00 committed by GitHub
parent 56e1d0a69d
commit 2262681351
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 1 deletions

View File

@ -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<tab>)
description: Shows ViaVersion Version and more.
aliases: [viaver, vvbukkit]

View File

@ -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<tab>)
this.handler = handler;
}

View File

@ -41,4 +41,9 @@ public class VelocityCommandHandler extends ViaCommandHandler implements SimpleC
public List<String> 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<tab>)
}
}