diff --git a/src/fr/neatmonster/nocheatplus/command/CommandUtil.java b/src/fr/neatmonster/nocheatplus/command/CommandUtil.java index 39cc7e0b..51b562b1 100644 --- a/src/fr/neatmonster/nocheatplus/command/CommandUtil.java +++ b/src/fr/neatmonster/nocheatplus/command/CommandUtil.java @@ -1,10 +1,16 @@ package fr.neatmonster.nocheatplus.command; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.SimpleCommandMap; import org.bukkit.craftbukkit.CraftServer; +import fr.neatmonster.nocheatplus.checks.CheckType; + public class CommandUtil { public static SimpleCommandMap getCommandMap(){ @@ -30,4 +36,30 @@ public class CommandUtil { final String lcAlias = alias.trim().toLowerCase(); return map.getCommand(lcAlias); } + + /** + * + * @param input + * @return + */ + public static List getCheckTypeTabMatches(final String input) { + final String ref = input.toUpperCase().replace('-', '_').replace('.', '_'); + final List res = new ArrayList(); + for (final CheckType checkType : CheckType.values()){ + final String name = checkType.name(); + if (name.startsWith(ref)) res.add(name); + } + if (ref.indexOf('_') == -1){ + for (final CheckType checkType : CheckType.values()){ + final String name = checkType.name(); + final String[] split = name.split("_", 2); + if (split.length > 1 && split[1].startsWith(ref)) res.add(name); + } + } + if (!res.isEmpty()){ + Collections.sort(res); + return res; + } + return null; + } }