mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
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:
parent
c115afba85
commit
f883dfdf2c
14 changed files with 132 additions and 30 deletions
|
@ -63,4 +63,9 @@ public class BungeeCommandSender implements CommandSender {
|
|||
}
|
||||
return LanguageUtils.getDefaultLocale();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String permission) {
|
||||
return handle.hasPermission(permission);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,8 +35,8 @@ import org.geysermc.connector.command.GeyserCommand;
|
|||
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;
|
||||
|
||||
public class GeyserBungeeCommandExecutor extends Command implements TabExecutor {
|
||||
|
||||
|
@ -82,8 +82,9 @@ public class GeyserBungeeCommandExecutor extends Command implements TabExecutor
|
|||
@Override
|
||||
public Iterable<String> onTabComplete(CommandSender sender, String[] args) {
|
||||
if (args.length == 1) {
|
||||
return connector.getCommandManager().getCommandNames();
|
||||
return commandExecutor.tabComplete(new BungeeCommandSender(sender));
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,8 +35,8 @@ import org.geysermc.connector.command.GeyserCommand;
|
|||
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 GeyserSpigotCommandExecutor extends CommandExecutor implements TabExecutor {
|
||||
|
@ -78,8 +78,8 @@ public class GeyserSpigotCommandExecutor extends CommandExecutor implements TabE
|
|||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (args.length == 1) {
|
||||
return connector.getCommandManager().getCommandNames();
|
||||
return tabComplete(new SpigotCommandSender(sender));
|
||||
}
|
||||
return new ArrayList<>();
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,6 +73,11 @@ public class SpigotCommandSender implements CommandSender {
|
|||
return locale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String permission) {
|
||||
return handle.hasPermission(permission);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if we are on pre-1.12, and therefore {@code player.getLocale()} doesn't exist and we have to get
|
||||
* {@code player.spigot().getLocale()}.
|
||||
|
|
|
@ -8,21 +8,32 @@ api-version: 1.13
|
|||
commands:
|
||||
geyser:
|
||||
description: The main command for Geyser.
|
||||
usage: /geyser help
|
||||
usage: /geyser <subcommand>
|
||||
permissions:
|
||||
geyser.command.help:
|
||||
description: Shows help for all registered commands.
|
||||
geyser.command.advancement:
|
||||
description: Shows the advancements of the player on the server.
|
||||
geyser.command.dump:
|
||||
description: Dumps Geyser debug information for bug reports.
|
||||
geyser.command.list:
|
||||
description: List all players connected through Geyser.
|
||||
default: true
|
||||
geyser.command.offhand:
|
||||
description: Puts an items in your offhand.
|
||||
geyser.command.reload:
|
||||
description: Reloads the Geyser configurations. Kicks all players when used!
|
||||
default: true
|
||||
geyser.command.advancements:
|
||||
description: Shows the advancements of the player on the server.
|
||||
default: true
|
||||
geyser.command.statistics:
|
||||
description: Shows the statistics of the player on the server.
|
||||
default: true
|
||||
geyser.command.settings:
|
||||
description: Modify user settings
|
||||
default: true
|
||||
geyser.command.list:
|
||||
description: List all players connected through Geyser.
|
||||
default: op
|
||||
geyser.command.dump:
|
||||
description: Dumps Geyser debug information for bug reports.
|
||||
default: op
|
||||
geyser.command.reload:
|
||||
description: Reloads the Geyser configurations. Kicks all players when used!
|
||||
default: false
|
||||
geyser.command.version:
|
||||
description: Shows the current Geyser version and checks for updates.
|
||||
description: Shows the current Geyser version and checks for updates.
|
||||
default: op
|
|
@ -40,8 +40,8 @@ import org.spongepowered.api.world.Location;
|
|||
import org.spongepowered.api.world.World;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
|
@ -82,9 +82,9 @@ public class GeyserSpongeCommandExecutor extends CommandExecutor implements Comm
|
|||
@Override
|
||||
public List<String> getSuggestions(CommandSource source, String arguments, @Nullable Location<World> targetPosition) {
|
||||
if (arguments.split(" ").length == 1) {
|
||||
return connector.getCommandManager().getCommandNames();
|
||||
return tabComplete(new SpongeCommandSender(source));
|
||||
}
|
||||
return new ArrayList<>();
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -51,4 +51,9 @@ public class SpongeCommandSender implements CommandSender {
|
|||
public boolean isConsole() {
|
||||
return handle instanceof ConsoleSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String permission) {
|
||||
return handle.hasPermission(permission);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -110,4 +110,9 @@ public class GeyserStandaloneLogger extends SimpleTerminalConsole implements Gey
|
|||
public boolean isConsole() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String permission) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,4 +72,9 @@ public class VelocityCommandSender implements CommandSender {
|
|||
}
|
||||
return LanguageUtils.getDefaultLocale();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String permission) {
|
||||
return handle.hasPermission(permission);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue