Skip to content

Commit

Permalink
Limit /plot trust remove suggestions to trusted residents (#7599)
Browse files Browse the repository at this point in the history
  • Loading branch information
Warriorrrr authored Sep 15, 2024
1 parent fa5f5c4 commit 471270e
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String commandLabel,

@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
if (sender instanceof Player) {
if (sender instanceof Player player) {
switch (args[0].toLowerCase(Locale.ROOT)) {
case "set":
if (args.length == 2) {
Expand Down Expand Up @@ -298,8 +298,16 @@ else if (args.length == 3)
case "trust":
if (args.length == 2)
return NameUtil.filterByStart(Arrays.asList("add", "remove"), args[1]);
if (args.length == 3)
return getTownyStartingWith(args[2], "r");
if (args.length == 3) {
if ("remove".equalsIgnoreCase(args[1])) {
final TownBlock townBlock = WorldCoord.parseWorldCoord(player).getTownBlockOrNull();
if (townBlock != null) {
return townBlock.getTrustedResidents().stream().map(Resident::getName).toList();
}
} else {
return getTownyStartingWith(args[2], "r");
}
}
default:
if (args.length == 1)
return NameUtil.filterByStart(TownyCommandAddonAPI.getTabCompletes(CommandType.PLOT, plotTabCompletes), args[0]);
Expand Down

0 comments on commit 471270e

Please # to comment.