From a3a31fd2dd2e1c77c800a1e0a4d9fa37784b33dc Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Sun, 5 Jul 2015 02:19:45 +0200 Subject: [PATCH] Correct handling of command's parameters for tab completion Hi :) There is some problem with TabExecutor and I think I found the problem. Exemple : /send When I write "/send " (with trailing space) and press Tab, I don't have any suggestion. But when I wrote the first character of an online player, it suggest all players which start with this same character (expected behavior) The problem is the same when I wrote "/send marcbal " (with trailing space). When I press Tab key, I have "marcbal" suggested instead of servers suggestion. (the result is "/send marcbal marcbal"). But when i wrote the first character of a server name, it suggest all servers which start with this same character (expected behavior) other exemple : there is 2 players online in the same server : me (marcbal) and marcbaleeee (for exemple) when I wrote "/send marcbal " (with trailing space) and I press Tab key, I have the suggestion of the 2 player names. I deduced that the onTabComplete() don't care about the trailing space of the command string (exemple : "/send marcbal ") and probably a problem when splitting (removing last trailing empty args), so, the onTabComplete method try to complete the first argument "marcbal" instead of the second empty argument. To split the command line, you use the method Pattern.split(CharSequence) that remove trailing empty strings http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html#split(java.lang.CharSequence) So, we should use the other split() method, with a second argument which has to be a negative integer value. (see Javadoc) PS : Sorry for my bad english x) --- api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java b/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java index 91ab95ad..cde82027 100644 --- a/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java +++ b/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java @@ -126,7 +126,7 @@ public class PluginManager */ public boolean dispatchCommand(CommandSender sender, String commandLine, List tabResults) { - String[] split = argsSplit.split( commandLine ); + String[] split = argsSplit.split( commandLine, -1 ); // Check for chat that only contains " " if ( split.length == 0 ) {