Almost finish tab completion, #77 (see details)
The only commands left to enable tab completion on are: - jail - jail transfer
This commit is contained in:
parent
019deea43a
commit
cfb62eed13
@ -208,8 +208,7 @@ public class JailMain extends JavaPlugin {
|
|||||||
if(commandLabel.equalsIgnoreCase("jail") || commandLabel.equalsIgnoreCase("j")) {
|
if(commandLabel.equalsIgnoreCase("jail") || commandLabel.equalsIgnoreCase("j")) {
|
||||||
return jh.parseTabComplete(jm, sender, args);
|
return jh.parseTabComplete(jm, sender, args);
|
||||||
}else {
|
}else {
|
||||||
//cmdHand.handleCommand(jm, sender, command.getName().toLowerCase(), args);
|
return cmdHand.parseTabComplete(jm, sender, command.getName().toLowerCase(), args);
|
||||||
//unjail,etc
|
|
||||||
}
|
}
|
||||||
}catch(Exception e) {
|
}catch(Exception e) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
|
@ -11,6 +11,7 @@ import java.util.UUID;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import com.graywolf336.jail.beans.CachePrisoner;
|
import com.graywolf336.jail.beans.CachePrisoner;
|
||||||
import com.graywolf336.jail.beans.Cell;
|
import com.graywolf336.jail.beans.Cell;
|
||||||
@ -84,12 +85,26 @@ public class JailManager {
|
|||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a List of the jail names. */
|
/**
|
||||||
public List<String> getJailNamesAsList() {
|
* Gets a list of Jail names that start with the provided prefix.
|
||||||
|
*
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* If the provided prefix is empty, then we add all of the jails.
|
||||||
|
*
|
||||||
|
* @param prefix The start of the jails to get
|
||||||
|
* @return List of jails that matched the prefix
|
||||||
|
*/
|
||||||
|
public List<String> getJailsByPrefix(String prefix) {
|
||||||
List<String> results = new ArrayList<String>();
|
List<String> results = new ArrayList<String>();
|
||||||
|
|
||||||
for(Jail j : this.jails.values())
|
for(Jail j : this.jails.values()) {
|
||||||
|
if(!prefix.isEmpty() && StringUtil.startsWithIgnoreCase(j.getName(), prefix)) {
|
||||||
results.add(j.getName());
|
results.add(j.getName());
|
||||||
|
}else {
|
||||||
|
results.add(j.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Collections.sort(results);
|
Collections.sort(results);
|
||||||
|
|
||||||
|
@ -92,10 +92,17 @@ public class Util {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getStringFromArray(String separator, String... list) {
|
/**
|
||||||
|
* Gets a single string from an array of strings, separated by the separator.
|
||||||
|
*
|
||||||
|
* @param separator The item to separate the items
|
||||||
|
* @param array The array of strings to combine
|
||||||
|
* @return the resulting combined string
|
||||||
|
*/
|
||||||
|
public static String getStringFromArray(String separator, String... array) {
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
|
|
||||||
for(String s : list) {
|
for(String s : array) {
|
||||||
if(result.length() != 0) result.append(separator);
|
if(result.length() != 0) result.append(separator);
|
||||||
result.append(s);
|
result.append(s);
|
||||||
}
|
}
|
||||||
@ -103,6 +110,13 @@ public class Util {
|
|||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a single string from a list of strings, separated by the separator.
|
||||||
|
*
|
||||||
|
* @param separator The item to separate the items
|
||||||
|
* @param list The list of strings to combine
|
||||||
|
* @return the resulting combined string
|
||||||
|
*/
|
||||||
public static String getStringFromList(String separator, List<String> list) {
|
public static String getStringFromList(String separator, List<String> list) {
|
||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.graywolf336.jail.command;
|
package com.graywolf336.jail.command;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
@ -18,7 +19,7 @@ import com.graywolf336.jail.command.commands.UnJailForceCommand;
|
|||||||
import com.graywolf336.jail.enums.Lang;
|
import com.graywolf336.jail.enums.Lang;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Where all the commands are registered at and handled, processed, at.
|
* Where all the commands are registered, handled, and processed.
|
||||||
*
|
*
|
||||||
* @author graywolf336
|
* @author graywolf336
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
@ -35,6 +36,28 @@ public class CommandHandler {
|
|||||||
plugin.debug("Loaded " + commands.size() + " commands.");
|
plugin.debug("Loaded " + commands.size() + " commands.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> parseTabComplete(JailManager jm, CommandSender sender, String commandLine, String[] args) throws Exception {
|
||||||
|
List<Command> matches = getMatches(commandLine);
|
||||||
|
|
||||||
|
if(matches.size() == 0 || matches.size() > 1) return Collections.emptyList();
|
||||||
|
else {
|
||||||
|
CommandInfo i = matches.get(0).getClass().getAnnotation(CommandInfo.class);
|
||||||
|
|
||||||
|
//Sender provided too many arguments which means there
|
||||||
|
//is nothing to tab complete
|
||||||
|
if(i.maxArgs() != -1 && i.maxArgs() < args.length) return Collections.emptyList();
|
||||||
|
|
||||||
|
//Don't return anything if a player is required and they're not a player
|
||||||
|
if(i.needsPlayer() && !(sender instanceof Player)) return Collections.emptyList();
|
||||||
|
|
||||||
|
//Don't return anything if they don't have permission
|
||||||
|
if(!sender.hasPermission(i.permission())) return Collections.emptyList();
|
||||||
|
|
||||||
|
//Let the command handle the rest of it
|
||||||
|
return matches.get(0).provideTabCompletions(jm, sender, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the given command and checks that the command is in valid form.
|
* Handles the given command and checks that the command is in valid form.
|
||||||
*
|
*
|
||||||
|
@ -40,6 +40,14 @@ import com.graywolf336.jail.command.subcommands.JailVersionCommand;
|
|||||||
import com.graywolf336.jail.command.subcommands.JailVoteCommand;
|
import com.graywolf336.jail.command.subcommands.JailVoteCommand;
|
||||||
import com.graywolf336.jail.enums.Lang;
|
import com.graywolf336.jail.enums.Lang;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where all the <strong>jail</strong> commands are registered, handled, and processed at.
|
||||||
|
*
|
||||||
|
* @author graywolf336
|
||||||
|
* @since 3.0.0
|
||||||
|
* @version 1.1.0
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class JailHandler {
|
public class JailHandler {
|
||||||
private LinkedHashMap<String, Command> commands;
|
private LinkedHashMap<String, Command> commands;
|
||||||
|
|
||||||
@ -51,7 +59,7 @@ public class JailHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<String> parseTabComplete(JailManager jm, CommandSender sender, String[] args) throws Exception {
|
public List<String> parseTabComplete(JailManager jm, CommandSender sender, String[] args) throws Exception {
|
||||||
if(args[0].equalsIgnoreCase("") || args.length == 1) {
|
if(args[0].isEmpty() || args.length == 1) {
|
||||||
List<String> results = new ArrayList<String>();
|
List<String> results = new ArrayList<String>();
|
||||||
String arg0 = args[0].toLowerCase();
|
String arg0 = args[0].toLowerCase();
|
||||||
boolean hasJailPermission = false;
|
boolean hasJailPermission = false;
|
||||||
@ -70,7 +78,7 @@ public class JailHandler {
|
|||||||
//If the sender has permission to the command
|
//If the sender has permission to the command
|
||||||
//and the first argument (sub command) is empty OR
|
//and the first argument (sub command) is empty OR
|
||||||
//the first argument matches the command or starts with the string
|
//the first argument matches the command or starts with the string
|
||||||
if(sender.hasPermission(i.permission()) && (arg0.equalsIgnoreCase("") || (arg0.toLowerCase().matches(i.pattern()) || i.pattern().startsWith(arg0)))) {
|
if(sender.hasPermission(i.permission()) && (arg0.isEmpty() || (arg0.toLowerCase().matches(i.pattern()) || i.pattern().startsWith(arg0)))) {
|
||||||
results.add(i.pattern().split("\\|")[0]);
|
results.add(i.pattern().split("\\|")[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -79,12 +87,10 @@ public class JailHandler {
|
|||||||
Collections.sort(results);
|
Collections.sort(results);
|
||||||
|
|
||||||
//Don't send out all the players if they don't have jail permission
|
//Don't send out all the players if they don't have jail permission
|
||||||
if(hasJailPermission) {
|
if(hasJailPermission)
|
||||||
for(Player p : jm.getPlugin().getServer().getOnlinePlayers()) {
|
for(Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
||||||
if(arg0.equalsIgnoreCase("") || StringUtil.startsWithIgnoreCase(p.getName(), arg0))
|
if(arg0.isEmpty() || StringUtil.startsWithIgnoreCase(p.getName(), arg0))
|
||||||
results.add(p.getName());
|
results.add(p.getName());
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}else {
|
}else {
|
||||||
@ -93,16 +99,16 @@ public class JailHandler {
|
|||||||
for(Command c : commands.values()) {
|
for(Command c : commands.values()) {
|
||||||
CommandInfo i = c.getClass().getAnnotation(CommandInfo.class);
|
CommandInfo i = c.getClass().getAnnotation(CommandInfo.class);
|
||||||
|
|
||||||
|
//Sender provided too many arguments which means there
|
||||||
|
//is nothing to tab complete
|
||||||
|
if(i.maxArgs() != -1 && i.maxArgs() < args.length - 1) continue;
|
||||||
|
|
||||||
//Skip if the command requires a player and the sender isn't a player
|
//Skip if the command requires a player and the sender isn't a player
|
||||||
if(i.needsPlayer() && !(sender instanceof Player)) continue;
|
if(i.needsPlayer() && !(sender instanceof Player)) continue;
|
||||||
|
|
||||||
//If the sender doesn't have permission, we won't send them further
|
//If the sender doesn't have permission, we won't send them further
|
||||||
if(!sender.hasPermission(i.permission())) continue;
|
if(!sender.hasPermission(i.permission())) continue;
|
||||||
|
|
||||||
//Sender provided too many arguments which means there
|
|
||||||
//is nothing to tab complete
|
|
||||||
if(i.maxArgs() != -1 && i.maxArgs() < args.length - 1) continue;
|
|
||||||
|
|
||||||
if(arg0.toLowerCase().matches(i.pattern())) {
|
if(arg0.toLowerCase().matches(i.pattern())) {
|
||||||
return c.provideTabCompletions(jm, sender, args);
|
return c.provideTabCompletions(jm, sender, args);
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package com.graywolf336.jail.command.commands;
|
package com.graywolf336.jail.command.commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import com.graywolf336.jail.JailManager;
|
import com.graywolf336.jail.JailManager;
|
||||||
import com.graywolf336.jail.command.Command;
|
import com.graywolf336.jail.command.Command;
|
||||||
@ -43,7 +45,16 @@ public class HandCuffCommand implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||||
//TODO implement
|
List<String> results = new ArrayList<String>();
|
||||||
return Collections.emptyList();
|
|
||||||
|
for(Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
||||||
|
if(!jm.getPlugin().getHandCuffManager().isHandCuffed(p.getUniqueId())) //don't send someone who is already handcuffed
|
||||||
|
if(!p.hasPermission("jail.cantbehandcuffed")) //don't send someone who can't be handcuffed
|
||||||
|
if(args[0].isEmpty() || StringUtil.startsWithIgnoreCase(p.getName(), args[0]))
|
||||||
|
results.add(p.getName());
|
||||||
|
|
||||||
|
Collections.sort(results);
|
||||||
|
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package com.graywolf336.jail.command.commands;
|
package com.graywolf336.jail.command.commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import com.graywolf336.jail.JailManager;
|
import com.graywolf336.jail.JailManager;
|
||||||
import com.graywolf336.jail.command.Command;
|
import com.graywolf336.jail.command.Command;
|
||||||
@ -37,7 +39,15 @@ public class UnHandCuffCommand implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||||
//TODO implement
|
List<String> results = new ArrayList<String>();
|
||||||
return Collections.emptyList();
|
|
||||||
|
for(Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
||||||
|
if(jm.getPlugin().getHandCuffManager().isHandCuffed(p.getUniqueId())) //don't send someone who isn't already handcuffed
|
||||||
|
if(args[0].isEmpty() || StringUtil.startsWithIgnoreCase(p.getName(), args[0]))
|
||||||
|
results.add(p.getName());
|
||||||
|
|
||||||
|
Collections.sort(results);
|
||||||
|
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package com.graywolf336.jail.command.commands;
|
package com.graywolf336.jail.command.commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import com.graywolf336.jail.JailManager;
|
import com.graywolf336.jail.JailManager;
|
||||||
import com.graywolf336.jail.beans.Jail;
|
import com.graywolf336.jail.beans.Jail;
|
||||||
@ -65,7 +67,14 @@ public class UnJailCommand implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||||
//TODO implement
|
List<String> results = new ArrayList<String>();
|
||||||
return Collections.emptyList();
|
|
||||||
|
for(Prisoner p : jm.getAllPrisoners().values())
|
||||||
|
if(args[0].isEmpty() || StringUtil.startsWithIgnoreCase(p.getLastKnownName(), args[0]))
|
||||||
|
results.add(p.getLastKnownName());
|
||||||
|
|
||||||
|
Collections.sort(results);
|
||||||
|
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
package com.graywolf336.jail.command.commands;
|
package com.graywolf336.jail.command.commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import com.graywolf336.jail.JailManager;
|
import com.graywolf336.jail.JailManager;
|
||||||
|
import com.graywolf336.jail.beans.Prisoner;
|
||||||
import com.graywolf336.jail.command.Command;
|
import com.graywolf336.jail.command.Command;
|
||||||
import com.graywolf336.jail.command.CommandInfo;
|
import com.graywolf336.jail.command.CommandInfo;
|
||||||
import com.graywolf336.jail.enums.Lang;
|
import com.graywolf336.jail.enums.Lang;
|
||||||
@ -39,7 +42,14 @@ public class UnJailForceCommand implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||||
//TODO implement
|
List<String> results = new ArrayList<String>();
|
||||||
return Collections.emptyList();
|
|
||||||
|
for(Prisoner p : jm.getAllPrisoners().values())
|
||||||
|
if(args[0].isEmpty() || StringUtil.startsWithIgnoreCase(p.getLastKnownName(), args[0]))
|
||||||
|
results.add(p.getLastKnownName());
|
||||||
|
|
||||||
|
Collections.sort(results);
|
||||||
|
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.StringUtil;
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import com.graywolf336.jail.JailManager;
|
import com.graywolf336.jail.JailManager;
|
||||||
@ -54,6 +55,11 @@ public class JailCheckCommand implements Command{
|
|||||||
|
|
||||||
Collections.sort(results);
|
Collections.sort(results);
|
||||||
|
|
||||||
|
if(args.length == 1)
|
||||||
|
for(Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
||||||
|
if(!results.contains(p.getName()))
|
||||||
|
results.add(p.getName());
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
package com.graywolf336.jail.command.subcommands;
|
package com.graywolf336.jail.command.subcommands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.StringUtil;
|
|
||||||
|
|
||||||
import com.graywolf336.jail.JailManager;
|
import com.graywolf336.jail.JailManager;
|
||||||
import com.graywolf336.jail.beans.Jail;
|
import com.graywolf336.jail.beans.Jail;
|
||||||
@ -72,18 +70,6 @@ public class JailCreateCellCommand implements Command {
|
|||||||
//We shouldn't provide when they want a cell name
|
//We shouldn't provide when they want a cell name
|
||||||
if(args.length >= 3) return Collections.emptyList();
|
if(args.length >= 3) return Collections.emptyList();
|
||||||
|
|
||||||
List<String> results = new ArrayList<String>();
|
return jm.getJailsByPrefix(args.length == 2 ? args[1] : "");
|
||||||
|
|
||||||
for(Jail j : jm.getJails()) {
|
|
||||||
if(args.length == 2 && StringUtil.startsWithIgnoreCase(j.getName(), args[1])) {
|
|
||||||
results.add(j.getName());
|
|
||||||
}else {
|
|
||||||
results.add(j.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Collections.sort(results);
|
|
||||||
|
|
||||||
return results;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,19 +41,17 @@ public class JailDeleteCellCommand implements Command {
|
|||||||
|
|
||||||
switch(args.length) {
|
switch(args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
results.addAll(jm.getJailNamesAsList());
|
results.addAll(jm.getJailsByPrefix(""));
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
for(Jail j : jm.getJails())
|
results = jm.getJailsByPrefix(args[1]);
|
||||||
if(StringUtil.startsWithIgnoreCase(j.getName(), args[1]))
|
|
||||||
results.add(j.getName());
|
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if(jm.isValidJail(args[1])) {
|
if(jm.isValidJail(args[1])) {
|
||||||
Jail j = jm.getJail(args[1]);
|
Jail j = jm.getJail(args[1]);
|
||||||
|
|
||||||
for(Cell c : j.getCells())
|
for(Cell c : j.getCells())
|
||||||
if(StringUtil.startsWithIgnoreCase(c.getName(), args[2]))
|
if(args[2].isEmpty() || StringUtil.startsWithIgnoreCase(c.getName(), args[2]))
|
||||||
results.add(c.getName());
|
results.add(c.getName());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.graywolf336.jail.command.subcommands;
|
package com.graywolf336.jail.command.subcommands;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -33,7 +32,6 @@ public class JailDeleteCellsCommand implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||||
//TODO implement
|
return jm.getJailsByPrefix(args.length == 2 ? args[1] : "");
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.graywolf336.jail.command.subcommands;
|
package com.graywolf336.jail.command.subcommands;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -33,7 +32,6 @@ public class JailDeleteCommand implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||||
//TODO implement
|
return jm.getJailsByPrefix(args.length == 2 ? args[1] : "");
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
package com.graywolf336.jail.command.subcommands;
|
package com.graywolf336.jail.command.subcommands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.util.StringUtil;
|
|
||||||
|
|
||||||
import com.graywolf336.jail.JailManager;
|
import com.graywolf336.jail.JailManager;
|
||||||
import com.graywolf336.jail.beans.Cell;
|
import com.graywolf336.jail.beans.Cell;
|
||||||
@ -58,18 +55,6 @@ public class JailListCellsCommand implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||||
List<String> results = new ArrayList<String>();
|
return jm.getJailsByPrefix(args.length == 2 ? args[1] : "");
|
||||||
|
|
||||||
for(Jail j : jm.getJails()) {
|
|
||||||
if(args.length == 2 && StringUtil.startsWithIgnoreCase(j.getName(), args[1])) {
|
|
||||||
results.add(j.getName());
|
|
||||||
}else {
|
|
||||||
results.add(j.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Collections.sort(results);
|
|
||||||
|
|
||||||
return results;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,10 @@
|
|||||||
package com.graywolf336.jail.command.subcommands;
|
package com.graywolf336.jail.command.subcommands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.util.StringUtil;
|
|
||||||
|
|
||||||
import com.graywolf336.jail.JailManager;
|
import com.graywolf336.jail.JailManager;
|
||||||
import com.graywolf336.jail.beans.Jail;
|
import com.graywolf336.jail.beans.Jail;
|
||||||
@ -67,18 +64,6 @@ public class JailListCommand implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||||
List<String> results = new ArrayList<String>();
|
return jm.getJailsByPrefix(args.length == 2 ? args[1] : "");
|
||||||
|
|
||||||
for(Jail j : jm.getJails()) {
|
|
||||||
if(args.length == 2 && StringUtil.startsWithIgnoreCase(j.getName(), args[1])) {
|
|
||||||
results.add(j.getName());
|
|
||||||
}else {
|
|
||||||
results.add(j.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Collections.sort(results);
|
|
||||||
|
|
||||||
return results;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.graywolf336.jail.command.subcommands;
|
package com.graywolf336.jail.command.subcommands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -7,6 +8,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import com.graywolf336.jail.JailManager;
|
import com.graywolf336.jail.JailManager;
|
||||||
import com.graywolf336.jail.beans.Prisoner;
|
import com.graywolf336.jail.beans.Prisoner;
|
||||||
@ -210,7 +212,24 @@ public class JailPayCommand implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||||
//TODO implement
|
if(jm.getPlugin().getConfig().getBoolean(Settings.JAILPAYENABLED.getPath())) {
|
||||||
|
switch(args.length) {
|
||||||
|
case 3:
|
||||||
|
List<String> results = new ArrayList<String>();
|
||||||
|
for(Prisoner p : jm.getAllPrisoners().values())
|
||||||
|
if(!p.isOfflinePending()) //Don't list if they're offline pending
|
||||||
|
if(p.getRemainingTime() != -1) //Don't list if they're jailed forever
|
||||||
|
if(StringUtil.startsWithIgnoreCase(p.getLastKnownName(), args[2]))
|
||||||
|
results.add(p.getLastKnownName());
|
||||||
|
|
||||||
|
Collections.sort(results);
|
||||||
|
|
||||||
|
return results;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ public class JailRecordCommand implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||||
//TODO implement
|
//We won't be implementing tab complete on this for now (unless requested)
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package com.graywolf336.jail.command.subcommands;
|
package com.graywolf336.jail.command.subcommands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import com.graywolf336.jail.JailManager;
|
import com.graywolf336.jail.JailManager;
|
||||||
import com.graywolf336.jail.beans.Jail;
|
import com.graywolf336.jail.beans.Jail;
|
||||||
@ -56,7 +58,21 @@ public class JailTeleInCommand implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||||
//TODO implement
|
switch(args.length) {
|
||||||
|
case 2:
|
||||||
|
return jm.getJailsByPrefix(args[1]);
|
||||||
|
case 3:
|
||||||
|
List<String> results = new ArrayList<String>();
|
||||||
|
|
||||||
|
for(Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
||||||
|
if(args[2].isEmpty() || StringUtil.startsWithIgnoreCase(p.getName(), args[2]))
|
||||||
|
results.add(p.getName());
|
||||||
|
|
||||||
|
Collections.sort(results);
|
||||||
|
|
||||||
|
return results;
|
||||||
|
default:
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package com.graywolf336.jail.command.subcommands;
|
package com.graywolf336.jail.command.subcommands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import com.graywolf336.jail.JailManager;
|
import com.graywolf336.jail.JailManager;
|
||||||
import com.graywolf336.jail.beans.Jail;
|
import com.graywolf336.jail.beans.Jail;
|
||||||
@ -56,7 +58,21 @@ public class JailTeleOutCommand implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||||
//TODO implement
|
switch(args.length) {
|
||||||
|
case 2:
|
||||||
|
return jm.getJailsByPrefix(args[1]);
|
||||||
|
case 3:
|
||||||
|
List<String> results = new ArrayList<String>();
|
||||||
|
|
||||||
|
for(Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
||||||
|
if(args[2].isEmpty() || StringUtil.startsWithIgnoreCase(p.getName(), args[2]))
|
||||||
|
results.add(p.getName());
|
||||||
|
|
||||||
|
Collections.sort(results);
|
||||||
|
|
||||||
|
return results;
|
||||||
|
default:
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package com.graywolf336.jail.command.subcommands;
|
package com.graywolf336.jail.command.subcommands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import com.graywolf336.jail.JailManager;
|
import com.graywolf336.jail.JailManager;
|
||||||
import com.graywolf336.jail.Util;
|
import com.graywolf336.jail.Util;
|
||||||
@ -57,7 +59,25 @@ public class JailTimeCommand implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||||
//TODO implement
|
List<String> results = new ArrayList<String>();
|
||||||
return Collections.emptyList();
|
|
||||||
|
switch(args.length) {
|
||||||
|
case 2:
|
||||||
|
for(String s : new String[] { "add", "remove", "set", "show" })
|
||||||
|
if(args[1].isEmpty() || StringUtil.startsWithIgnoreCase(s, args[1]))
|
||||||
|
results.add(s);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
for(Prisoner p : jm.getAllPrisoners().values())
|
||||||
|
if(StringUtil.startsWithIgnoreCase(p.getLastKnownName(), args[2]))
|
||||||
|
results.add(p.getLastKnownName());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Collections.sort(results);
|
||||||
|
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package com.graywolf336.jail.command.subcommands;
|
package com.graywolf336.jail.command.subcommands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import com.graywolf336.jail.JailManager;
|
import com.graywolf336.jail.JailManager;
|
||||||
import com.graywolf336.jail.beans.Jail;
|
import com.graywolf336.jail.beans.Jail;
|
||||||
@ -57,7 +59,21 @@ public class JailTransferAllCommand implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||||
//TODO implement
|
switch(args.length) {
|
||||||
|
case 2:
|
||||||
|
return jm.getJailsByPrefix(args[1]);
|
||||||
|
case 3:
|
||||||
|
List<String> results = new ArrayList<String>();
|
||||||
|
|
||||||
|
for(Jail j : jm.getJails())
|
||||||
|
if(!j.getName().equalsIgnoreCase(args[1]) && (args[2].isEmpty() || StringUtil.startsWithIgnoreCase(j.getName(), args[2])))
|
||||||
|
results.add(j.getName());
|
||||||
|
|
||||||
|
Collections.sort(results);
|
||||||
|
|
||||||
|
return results;
|
||||||
|
default:
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package com.graywolf336.jail.command.subcommands;
|
package com.graywolf336.jail.command.subcommands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
import com.graywolf336.jail.JailManager;
|
import com.graywolf336.jail.JailManager;
|
||||||
import com.graywolf336.jail.JailVoteManager;
|
import com.graywolf336.jail.JailVoteManager;
|
||||||
@ -102,7 +104,29 @@ public class JailVoteCommand implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) throws Exception {
|
||||||
//TODO implement
|
if(jm.getPlugin().getConfig().getBoolean(Settings.JAILVOTEENABLED.getPath()) && jm.getPlugin().getJailVoteManager() != null && !jm.getJails().isEmpty()) {
|
||||||
|
List<String> results = new ArrayList<String>();
|
||||||
|
|
||||||
|
switch(args.length) {
|
||||||
|
case 2:
|
||||||
|
for(Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
||||||
|
if(args[1].isEmpty() || StringUtil.startsWithIgnoreCase(p.getName(), args[1]))
|
||||||
|
results.add(p.getName());
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
for(String s : new String[] { "yes", "no" })
|
||||||
|
if(args[2].isEmpty() || StringUtil.startsWithIgnoreCase(s, args[2]))
|
||||||
|
results.add(s);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Collections.sort(results);
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}else {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user