fix: tab completion for /plot grant add/check <name> commands (#4720)

Fix tab completion for /plot grant add/check <name> commands

Fixed an issue where player name tab completion was not working correctly 
for /plot grant add <name> and /plot grant check <name> commands.

Previously, the tab completion logic would only attempt to complete player 
names after all arguments were processed, making it impossible to get 
player suggestions when typing the second argument.

Now the completion properly handles:
- /plot grant <TAB> → shows "add", "check" subcommands
- /plot grant add <TAB> → shows player list
- /plot grant check <TAB> → shows player list

Fixes #4382
This commit is contained in:
Leviaria
2025-08-06 21:44:10 +02:00
committed by GitHub
parent e5d36579b1
commit 4d2e4a3d1a

View File

@@ -177,8 +177,14 @@ public class Grant extends Command {
commands.addAll(TabCompletions.completePlayers(player, args[0], Collections.emptyList())); commands.addAll(TabCompletions.completePlayers(player, args[0], Collections.emptyList()));
} }
return commands; return commands;
} else if (args.length == 2) {
final String subcommand = args[0].toLowerCase();
if ((subcommand.equals("add") && player.hasPermission(Permission.PERMISSION_GRANT_ADD)) ||
(subcommand.equals("check") && player.hasPermission(Permission.PERMISSION_GRANT_CHECK))) {
return TabCompletions.completePlayers(player, args[1], Collections.emptyList());
}
} }
return TabCompletions.completePlayers(player, String.join(",", args).trim(), Collections.emptyList()); return Collections.emptyList();
} }
} }