From e32ec69a2485770bd46cd97e6e7e6da31368b018 Mon Sep 17 00:00:00 2001 From: Jason <11360596+jpenilla@users.noreply.github.com> Date: Wed, 12 Jan 2022 20:34:47 -0800 Subject: [PATCH] Improved KeyedWorldArgument suggestions (#334) --- .../paper/argument/KeyedWorldArgument.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cloud-minecraft/cloud-paper/src/main/java/cloud/commandframework/paper/argument/KeyedWorldArgument.java b/cloud-minecraft/cloud-paper/src/main/java/cloud/commandframework/paper/argument/KeyedWorldArgument.java index 53c6e3fc0..45adac78c 100644 --- a/cloud-minecraft/cloud-paper/src/main/java/cloud/commandframework/paper/argument/KeyedWorldArgument.java +++ b/cloud-minecraft/cloud-paper/src/main/java/cloud/commandframework/paper/argument/KeyedWorldArgument.java @@ -219,13 +219,14 @@ public Parser() { return this.parser.suggestions(commandContext, input); } - final List completions = new ArrayList<>(); - for (final World world : Bukkit.getWorlds()) { - if (world.getKey().getNamespace().equals(NamespacedKey.MINECRAFT)) { - completions.add(world.getKey().getKey()); - } else { - completions.add(world.getKey().toString()); + final List worlds = Bukkit.getWorlds(); + final List completions = new ArrayList<>(worlds.size() * 2); + for (final World world : worlds) { + final NamespacedKey key = world.getKey(); + if (!input.isEmpty() && key.getNamespace().equals(NamespacedKey.MINECRAFT_NAMESPACE)) { + completions.add(key.getKey()); } + completions.add(key.getNamespace() + ':' + key.getKey()); } return completions; }