Skip to content

Commit 374afdf

Browse files
committed
Improve tab completion and name auto-completion for plot trust command
Signed-off-by: William <will27528@gmail.com>
1 parent dad07c2 commit 374afdf

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

bukkit/src/main/java/me/william278/husktowns/commands/PlotCommand.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import me.william278.husktowns.cache.ClaimCache;
77
import me.william278.husktowns.cache.PlayerCache;
88
import me.william278.husktowns.chunk.ClaimedChunk;
9+
import me.william278.husktowns.util.NameAutoCompleter;
910
import org.bukkit.Bukkit;
1011
import org.bukkit.Location;
1112
import org.bukkit.command.Command;
@@ -127,7 +128,7 @@ protected void onCommand(Player player, Command command, String label, String[]
127128
if (args.length == 2) {
128129
final String playerToAdd = args[1];
129130
ClaimedChunk chunk = HuskTowns.getClaimCache().getChunkAt(playerLocation.getChunk().getX(), playerLocation.getChunk().getZ(), player.getWorld().getName());
130-
DataManager.addPlotMember(player, chunk, playerToAdd);
131+
DataManager.addPlotMember(player, chunk, NameAutoCompleter.getAutoCompletedName(playerToAdd));
131132
} else {
132133
MessageManager.sendMessage(player, "error_invalid_syntax", "/plot trust <player>");
133134
}
@@ -196,10 +197,7 @@ public List<String> onTabComplete(CommandSender sender, Command command, String
196197
case "trust":
197198
case "add":
198199
case "addmember":
199-
final HashSet<String> onlinePlayers = new HashSet<>();
200-
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
201-
onlinePlayers.add(onlinePlayer.getName());
202-
}
200+
final HashSet<String> onlinePlayers = new HashSet<>(HuskTowns.getPlayerList().getPlayers());
203201
if (onlinePlayers.isEmpty()) {
204202
return Collections.emptyList();
205203
}

0 commit comments

Comments
 (0)