Skip to content

Commit e32ec69

Browse files
committed
Improved KeyedWorldArgument suggestions (#334)
1 parent e109ecb commit e32ec69

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

cloud-minecraft/cloud-paper/src/main/java/cloud/commandframework/paper/argument/KeyedWorldArgument.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,14 @@ public Parser() {
219219
return this.parser.suggestions(commandContext, input);
220220
}
221221

222-
final List<String> completions = new ArrayList<>();
223-
for (final World world : Bukkit.getWorlds()) {
224-
if (world.getKey().getNamespace().equals(NamespacedKey.MINECRAFT)) {
225-
completions.add(world.getKey().getKey());
226-
} else {
227-
completions.add(world.getKey().toString());
222+
final List<World> worlds = Bukkit.getWorlds();
223+
final List<String> completions = new ArrayList<>(worlds.size() * 2);
224+
for (final World world : worlds) {
225+
final NamespacedKey key = world.getKey();
226+
if (!input.isEmpty() && key.getNamespace().equals(NamespacedKey.MINECRAFT_NAMESPACE)) {
227+
completions.add(key.getKey());
228228
}
229+
completions.add(key.getNamespace() + ':' + key.getKey());
229230
}
230231
return completions;
231232
}

0 commit comments

Comments
 (0)