Remove commands from autocomplete/help list that cannot be run (#2602)

* only tabcomplete for commands the sender has permission for

* set permission defaults for spigot

* Make velocity autocomplete on arg length 0 and 1

* fix advancements perm in spigot plugin.yml and add settings perm

(whoops)

* don't show bedrock commands to java players

* modify spigot perm defaults

* censor help menu, abstract tab complete code

* Bedrock players don't get cmd argument suggestions

* update spigot plugin.yml
This commit is contained in:
Konicai 2021-10-30 21:57:54 -04:00 committed by GitHub
parent c115afba85
commit f883dfdf2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 132 additions and 30 deletions

View file

@ -34,8 +34,8 @@ import org.geysermc.connector.common.ChatColor;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.utils.LanguageUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class GeyserVelocityCommandExecutor extends CommandExecutor implements SimpleCommand {
@ -71,9 +71,10 @@ public class GeyserVelocityCommandExecutor extends CommandExecutor implements Si
@Override
public List<String> suggest(Invocation invocation) {
if (invocation.arguments().length == 0) {
return connector.getCommandManager().getCommandNames();
// Velocity seems to do the splitting a bit differently. This results in the same behaviour in bungeecord/spigot.
if (invocation.arguments().length == 0 || invocation.arguments().length == 1) {
return tabComplete(new VelocityCommandSender(invocation.source()));
}
return new ArrayList<>();
return Collections.emptyList();
}
}

View file

@ -72,4 +72,9 @@ public class VelocityCommandSender implements CommandSender {
}
return LanguageUtils.getDefaultLocale();
}
@Override
public boolean hasPermission(String permission) {
return handle.hasPermission(permission);
}
}