Improved KeyedWorldArgument suggestions (#334)

This commit is contained in:
Jason 2022-01-12 20:34:47 -08:00
parent b0289e8d01
commit b3db0aab38

View file

@ -219,13 +219,14 @@ public final class KeyedWorldArgument<C> extends CommandArgument<C, World> {
return this.parser.suggestions(commandContext, input); return this.parser.suggestions(commandContext, input);
} }
final List<String> completions = new ArrayList<>(); final List<World> worlds = Bukkit.getWorlds();
for (final World world : Bukkit.getWorlds()) { final List<String> completions = new ArrayList<>(worlds.size() * 2);
if (world.getKey().getNamespace().equals(NamespacedKey.MINECRAFT)) { for (final World world : worlds) {
completions.add(world.getKey().getKey()); final NamespacedKey key = world.getKey();
} else { if (!input.isEmpty() && key.getNamespace().equals(NamespacedKey.MINECRAFT_NAMESPACE)) {
completions.add(world.getKey().toString()); completions.add(key.getKey());
} }
completions.add(key.getNamespace() + ':' + key.getKey());
} }
return completions; return completions;
} }