use of com.denizenscript.denizen.utilities.command.manager.Paginator in project Denizen-For-Bukkit by DenizenScript.
the class DenizenCommandHandler method scripts.
/*
* DENIZEN SCRIPTS
*/
@Command(aliases = { "denizen" }, usage = "scripts (--type assignment|task|...) (--filter string)", desc = "Lists currently loaded dScripts.", modifiers = { "scripts" }, min = 1, max = 4, permission = "denizen.basic")
public void scripts(CommandContext args, CommandSender sender) throws CommandException {
String type = null;
if (args.hasValueFlag("type")) {
type = args.getFlag("type");
}
String filter = null;
if (args.hasValueFlag("filter")) {
filter = args.getFlag("filter");
}
Set<String> scripts = ScriptRegistry.scriptContainers.keySet();
Paginator paginator = new Paginator().header("Scripts");
paginator.addLine("<e>Key: <a>Type <b>Name");
for (String script : scripts) {
ScriptContainer scriptContainer = ScriptRegistry.getScriptContainer(script);
if (type != null) {
if (scriptContainer.getContainerType().equalsIgnoreCase(type)) {
if (filter != null) {
if (script.contains(filter.toUpperCase())) {
paginator.addLine("<a>" + scriptContainer.getContainerType().substring(0, 3) + " <b>" + script);
}
} else {
paginator.addLine("<a>" + scriptContainer.getContainerType().substring(0, 3) + " <b>" + script);
}
}
} else if (filter != null) {
if (script.contains(filter.toUpperCase())) {
paginator.addLine("<a>" + scriptContainer.getContainerType().substring(0, 3) + " <b>" + script);
}
} else {
paginator.addLine("<a>" + scriptContainer.getContainerType().substring(0, 3) + " <b>" + script);
}
}
if (!paginator.sendPage(sender, args.getInteger(1, 1))) {
throw new CommandException("The page " + args.getInteger(1, 1) + " does not exist.");
}
}
Aggregations