diff --git a/proxy/src/main/java/proxy/network/ProxyHandler.java b/proxy/src/main/java/proxy/network/ProxyHandler.java index c2608ae..4547b08 100755 --- a/proxy/src/main/java/proxy/network/ProxyHandler.java +++ b/proxy/src/main/java/proxy/network/ProxyHandler.java @@ -393,31 +393,36 @@ public class ProxyHandler implements Handler { public void handleTabComplete(S3APacketTabComplete packetIn) { Handler.syncToMain(packetIn, this, this.proxy); - String[] comps = packetIn.getMatches(); - if(this.completion != null) { - if(this.admin && this.completion.startsWith("/")) { - if(this.completion.indexOf(' ') == -1) { - List list = Lists.newArrayList(comps); - if("/vproxy".regionMatches(true, 0, this.completion, 0, this.completion.length())) - list.add("/vproxy"); - Collections.sort(list); - this.sendToClient(new S3APacketTabComplete(list.toArray(new String[list.size()]))); - this.completion = null; - return; - } - else if(this.completion.startsWith("/vproxy ")) { - String[] args = this.completion.split(" ", -1); - String[] argv = new String[args.length - 1]; - System.arraycopy(args, 1, argv, 0, argv.length); - List list = this.getCompletions(argv); - this.sendToClient(new S3APacketTabComplete(list.toArray(new String[list.size()]))); - this.completion = null; - return; - } - } - this.completion = null; + if(this.completion == null) { + this.sendToClient(new S3APacketTabComplete(new String[0])); + return; } - this.sendToClient(packetIn); + List list = null; + if(this.completion.startsWith("/")) { + if(this.completion.indexOf(' ') == -1) { + list = Lists.newArrayList(packetIn.getMatches()); + if(this.admin && "/vproxy".regionMatches(true, 0, this.completion, 0, this.completion.length())) + list.add("/vproxy"); + Collections.sort(list); + } + else if(this.admin && this.completion.startsWith("/vproxy ")) { + String[] args = this.completion.split(" ", -1); + String[] argv = new String[args.length - 1]; + System.arraycopy(args, 1, argv, 0, argv.length); + list = this.getCompletions(argv); + } + } + else { + String[] args = this.completion.split(" ", -1); + String param = args[args.length - 1]; + list = Lists.newArrayList(); + for(ProxyHandler player : this.proxy.getPlayers()) { + if(player.getUsername().regionMatches(true, 0, param, 0, param.length())) + list.add(player.getUsername()); + } + } + this.sendToClient(list != null ? new S3APacketTabComplete(list.toArray(new String[list.size()])) : packetIn); + this.completion = null; } public void processPlayerDigging(C07PacketPlayerDigging packetIn) { diff --git a/proxy/src/main/java/proxy/util/Formatter.java b/proxy/src/main/java/proxy/util/Formatter.java index c3b0ecd..8714f72 100755 --- a/proxy/src/main/java/proxy/util/Formatter.java +++ b/proxy/src/main/java/proxy/util/Formatter.java @@ -77,7 +77,7 @@ public enum Formatter { } public static String joinSpace(String ... objs) { - return joinSpace(objs); + return joinSpace((Object[])objs); } public static String joinSpace(Object ... objs) {