Filter auto-complete arguments
This commit is contained in:
+2
-2
@@ -6,7 +6,7 @@ import us.ajg0702.queue.commands.BaseCommand;
|
|||||||
import us.ajg0702.queue.common.QueueMain;
|
import us.ajg0702.queue.common.QueueMain;
|
||||||
import us.ajg0702.utils.common.Messages;
|
import us.ajg0702.utils.common.Messages;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SlashServerCommand extends BaseCommand {
|
public class SlashServerCommand extends BaseCommand {
|
||||||
@@ -60,6 +60,6 @@ public class SlashServerCommand extends BaseCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> autoComplete(ICommandSender sender, String[] args) {
|
public List<String> autoComplete(ICommandSender sender, String[] args) {
|
||||||
return new ArrayList<>();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -11,6 +11,7 @@ import us.ajg0702.queue.common.QueueMain;
|
|||||||
import us.ajg0702.utils.common.Messages;
|
import us.ajg0702.utils.common.Messages;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class LeaveCommand extends BaseCommand {
|
public class LeaveCommand extends BaseCommand {
|
||||||
@@ -105,11 +106,12 @@ public class LeaveCommand extends BaseCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> autoComplete(ICommandSender sender, String[] args) {
|
public List<String> autoComplete(ICommandSender sender, String[] args) {
|
||||||
|
if(args.length > 1) return Collections.emptyList();
|
||||||
List<QueuePlayer> servers = main.getQueueManager().findPlayerInQueues(main.getPlatformMethods().senderToPlayer(sender));
|
List<QueuePlayer> servers = main.getQueueManager().findPlayerInQueues(main.getPlatformMethods().senderToPlayer(sender));
|
||||||
List<String> serverNames = new ArrayList<>();
|
List<String> serverNames = new ArrayList<>();
|
||||||
for(QueuePlayer queuePlayer : servers) {
|
for(QueuePlayer queuePlayer : servers) {
|
||||||
serverNames.add(queuePlayer.getQueueServer().getName());
|
serverNames.add(queuePlayer.getQueueServer().getName());
|
||||||
}
|
}
|
||||||
return serverNames;
|
return filterCompletion(serverNames, args[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import us.ajg0702.queue.commands.BaseCommand;
|
|||||||
import us.ajg0702.queue.common.QueueMain;
|
import us.ajg0702.queue.common.QueueMain;
|
||||||
import us.ajg0702.utils.common.Messages;
|
import us.ajg0702.utils.common.Messages;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ListCommand extends BaseCommand {
|
public class ListCommand extends BaseCommand {
|
||||||
@@ -79,6 +79,6 @@ public class ListCommand extends BaseCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> autoComplete(ICommandSender sender, String[] args) {
|
public List<String> autoComplete(ICommandSender sender, String[] args) {
|
||||||
return new ArrayList<>();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,10 +81,10 @@ public class Kick extends SubCommand {
|
|||||||
@Override
|
@Override
|
||||||
public List<String> autoComplete(ICommandSender sender, String[] args) {
|
public List<String> autoComplete(ICommandSender sender, String[] args) {
|
||||||
if(args.length == 1) {
|
if(args.length == 1) {
|
||||||
return main.getPlatformMethods().getPlayerNames(false);
|
return filterCompletion(main.getPlatformMethods().getPlayerNames(false), args[0]);
|
||||||
}
|
}
|
||||||
if(args.length == 2) {
|
if(args.length == 2) {
|
||||||
return main.getQueueManager().getServerNames();
|
return filterCompletion(main.getQueueManager().getServerNames(), args[1]);
|
||||||
}
|
}
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import us.ajg0702.queue.common.QueueMain;
|
|||||||
import us.ajg0702.utils.common.Messages;
|
import us.ajg0702.utils.common.Messages;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class KickAll extends SubCommand {
|
public class KickAll extends SubCommand {
|
||||||
@@ -65,9 +66,9 @@ public class KickAll extends SubCommand {
|
|||||||
@Override
|
@Override
|
||||||
public List<String> autoComplete(ICommandSender sender, String[] args) {
|
public List<String> autoComplete(ICommandSender sender, String[] args) {
|
||||||
if(args.length == 1) {
|
if(args.length == 1) {
|
||||||
return main.getQueueManager().getServerNames();
|
return filterCompletion(main.getQueueManager().getServerNames(), args[0]);
|
||||||
}
|
}
|
||||||
return new ArrayList<>();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -104,6 +104,6 @@ public class ManageCommand extends BaseCommand {
|
|||||||
commands.add(subCommand.getName());
|
commands.add(subCommand.getName());
|
||||||
commands.addAll(subCommand.getAliases());
|
commands.addAll(subCommand.getAliases());
|
||||||
}
|
}
|
||||||
return commands;
|
return filterCompletion(commands, args[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,11 +77,11 @@ public class Pause extends SubCommand {
|
|||||||
if(args.length == 1) {
|
if(args.length == 1) {
|
||||||
List<String> servers = new ArrayList<>(main.getQueueManager().getServerNames());
|
List<String> servers = new ArrayList<>(main.getQueueManager().getServerNames());
|
||||||
servers.add("all");
|
servers.add("all");
|
||||||
return servers;
|
return filterCompletion(servers, args[0]);
|
||||||
}
|
}
|
||||||
if(args.length == 2) {
|
if(args.length == 2) {
|
||||||
return Arrays.asList("on", "off", "true", "false");
|
return filterCompletion(Arrays.asList("on", "off", "true", "false"), args[1]);
|
||||||
}
|
}
|
||||||
return new ArrayList<>();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import us.ajg0702.queue.commands.SubCommand;
|
|||||||
import us.ajg0702.queue.common.QueueMain;
|
import us.ajg0702.queue.common.QueueMain;
|
||||||
import us.ajg0702.utils.common.Messages;
|
import us.ajg0702.utils.common.Messages;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@@ -88,6 +88,6 @@ public class QueueList extends SubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public java.util.List<String> autoComplete(ICommandSender sender, String[] args) {
|
public java.util.List<String> autoComplete(ICommandSender sender, String[] args) {
|
||||||
return new ArrayList<>();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import us.ajg0702.queue.commands.SubCommand;
|
|||||||
import us.ajg0702.queue.common.QueueMain;
|
import us.ajg0702.queue.common.QueueMain;
|
||||||
import us.ajg0702.utils.common.Messages;
|
import us.ajg0702.utils.common.Messages;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Reload extends SubCommand {
|
public class Reload extends SubCommand {
|
||||||
@@ -63,6 +63,6 @@ public class Reload extends SubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> autoComplete(ICommandSender sender, String[] args) {
|
public List<String> autoComplete(ICommandSender sender, String[] args) {
|
||||||
return new ArrayList<>();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import us.ajg0702.queue.common.QueueMain;
|
|||||||
import us.ajg0702.utils.common.Messages;
|
import us.ajg0702.utils.common.Messages;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class Send extends SubCommand {
|
public class Send extends SubCommand {
|
||||||
@@ -93,12 +94,12 @@ public class Send extends SubCommand {
|
|||||||
if(args.length == 1) {
|
if(args.length == 1) {
|
||||||
List<String> options = new ArrayList<>(main.getPlatformMethods().getServerNames());
|
List<String> options = new ArrayList<>(main.getPlatformMethods().getServerNames());
|
||||||
options.addAll(main.getPlatformMethods().getPlayerNames(false));
|
options.addAll(main.getPlatformMethods().getPlayerNames(false));
|
||||||
return options;
|
return filterCompletion(options, args[0]);
|
||||||
}
|
}
|
||||||
if(args.length == 2) {
|
if(args.length == 2) {
|
||||||
return main.getQueueManager().getServerNames();
|
return filterCompletion(main.getQueueManager().getServerNames(), args[1]);
|
||||||
}
|
}
|
||||||
return new ArrayList<>();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,10 +8,7 @@ import us.ajg0702.queue.commands.BaseCommand;
|
|||||||
import us.ajg0702.queue.common.QueueMain;
|
import us.ajg0702.queue.common.QueueMain;
|
||||||
import us.ajg0702.utils.common.Messages;
|
import us.ajg0702.utils.common.Messages;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public class QueueCommand extends BaseCommand {
|
public class QueueCommand extends BaseCommand {
|
||||||
@@ -92,7 +89,7 @@ public class QueueCommand extends BaseCommand {
|
|||||||
@Override
|
@Override
|
||||||
public List<String> autoComplete(ICommandSender sender, String[] args) {
|
public List<String> autoComplete(ICommandSender sender, String[] args) {
|
||||||
if(!main.getConfig().getBoolean("tab-complete-queues")) {
|
if(!main.getConfig().getBoolean("tab-complete-queues")) {
|
||||||
return new ArrayList<>();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
if(args.length == 1) {
|
if(args.length == 1) {
|
||||||
List<String> servers = filterCompletion(main.getQueueManager().getServerNames(), args[0]);
|
List<String> servers = filterCompletion(main.getQueueManager().getServerNames(), args[0]);
|
||||||
@@ -101,6 +98,6 @@ public class QueueCommand extends BaseCommand {
|
|||||||
}
|
}
|
||||||
return servers;
|
return servers;
|
||||||
}
|
}
|
||||||
return new ArrayList<>();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user