Fix tab completions not being returned for empty strings (#538)

This commit is contained in:
Luck 2017-11-07 22:16:48 +00:00
parent 175a21c0e4
commit 3e8f7911af
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
3 changed files with 6 additions and 3 deletions

View File

@ -40,6 +40,7 @@ import org.bukkit.command.TabExecutor;
import java.util.List;
public class BukkitCommandExecutor extends CommandManager implements CommandExecutor, TabExecutor {
private static final Splitter TAB_COMPLETE_ARGUMENT_SPLITTER = Splitter.on(COMMAND_SEPARATOR_PATTERN);
private static final Splitter ARGUMENT_SPLITTER = Splitter.on(COMMAND_SEPARATOR_PATTERN).omitEmptyStrings();
private static final Joiner ARGUMENT_JOINER = Joiner.on(' ');
@ -62,7 +63,7 @@ public class BukkitCommandExecutor extends CommandManager implements CommandExec
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
Sender lpSender = plugin.getSenderFactory().wrap(sender);
List<String> arguments = Util.stripQuotes(ARGUMENT_SPLITTER.splitToList(ARGUMENT_JOINER.join(args)));
List<String> arguments = Util.stripQuotes(TAB_COMPLETE_ARGUMENT_SPLITTER.splitToList(ARGUMENT_JOINER.join(args)));
return onTabComplete(lpSender, arguments);
}

View File

@ -39,6 +39,7 @@ import net.md_5.bungee.api.plugin.TabExecutor;
import java.util.List;
public class BungeeCommandExecutor extends Command implements TabExecutor {
private static final Splitter TAB_COMPLETE_ARGUMENT_SPLITTER = Splitter.on(CommandManager.COMMAND_SEPARATOR_PATTERN);
private static final Splitter ARGUMENT_SPLITTER = Splitter.on(CommandManager.COMMAND_SEPARATOR_PATTERN).omitEmptyStrings();
private static final Joiner ARGUMENT_JOINER = Joiner.on(' ');
@ -62,7 +63,7 @@ public class BungeeCommandExecutor extends Command implements TabExecutor {
@Override
public Iterable<String> onTabComplete(CommandSender sender, String[] args) {
Sender lpSender = plugin.getSenderFactory().wrap(sender);
List<String> arguments = Util.stripQuotes(ARGUMENT_SPLITTER.splitToList(ARGUMENT_JOINER.join(args)));
List<String> arguments = Util.stripQuotes(TAB_COMPLETE_ARGUMENT_SPLITTER.splitToList(ARGUMENT_JOINER.join(args)));
return manager.onTabComplete(lpSender, arguments);
}

View File

@ -47,6 +47,7 @@ import java.util.Optional;
import javax.annotation.Nullable;
public class SpongeCommandExecutor extends CommandManager implements CommandCallable {
private static final Splitter TAB_COMPLETE_ARGUMENT_SPLITTER = Splitter.on(COMMAND_SEPARATOR_PATTERN);
private static final Splitter ARGUMENT_SPLITTER = Splitter.on(COMMAND_SEPARATOR_PATTERN).omitEmptyStrings();
private final LPSpongePlugin plugin;
@ -68,7 +69,7 @@ public class SpongeCommandExecutor extends CommandManager implements CommandCall
@Override
public List<String> getSuggestions(CommandSource source, String s, @Nullable Location<World> location) {
Sender lpSender = plugin.getSenderFactory().wrap(source);
List<String> arguments = processSelectors(source, Util.stripQuotes(ARGUMENT_SPLITTER.splitToList(s)));
List<String> arguments = processSelectors(source, Util.stripQuotes(TAB_COMPLETE_ARGUMENT_SPLITTER.splitToList(s)));
return onTabComplete(lpSender, arguments);
}