Skip to content

Commit fc925ec

Browse files
committed
Better Tab Completition
1 parent 0f8c185 commit fc925ec

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/main/java/com/lojosho/enchantnow/commands/EnchantBookTabComplete.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class EnchantBookTabComplete implements TabCompleter {
1818
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
1919

2020
List<String> completitions = new ArrayList<>();
21+
List<String> final_completitions = new ArrayList<>();
2122

2223
if (args.length == 1) {
2324

@@ -52,7 +53,7 @@ else if (args.length == 3) {
5253
}
5354
}
5455

55-
Collections.sort(completitions);
56-
return completitions;
56+
StringUtil.copyPartialMatches(args[0], completitions, final_completitions);
57+
return final_completitions;
5758
}
5859
}

src/main/java/com/lojosho/enchantnow/commands/EnchantTabComplete.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class EnchantTabComplete implements TabCompleter {
1818
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
1919

2020
List<String> completitions = new ArrayList<>();
21+
List<String> final_completitions = new ArrayList<>();
2122

2223
if (args.length == 1) {
2324

@@ -37,17 +38,14 @@ public List<String> onTabComplete(CommandSender sender, Command command, String
3738
completitions.add(a);
3839
}
3940
}
40-
41-
StringUtil.copyPartialMatches(processedArg, processedEnchants, completitions);
42-
4341
}
4442
else if (args.length == 2) {
4543
for (Player player : Bukkit.getOnlinePlayers()) {
4644
completitions.add(player.getName());
4745
}
4846
}
4947

50-
Collections.sort(completitions);
51-
return completitions;
48+
StringUtil.copyPartialMatches(args[0], completitions, final_completitions);
49+
return final_completitions;
5250
}
5351
}

0 commit comments

Comments
 (0)