use of com.sk89q.worldedit.util.task.TaskStateComparator in project WorldGuard by EngineHub.
the class WorldGuardCommands method listRunningTasks.
@Command(aliases = { "running", "queue" }, desc = "List running tasks", max = 0)
@CommandPermissions("worldguard.running")
public void listRunningTasks(CommandContext args, Actor sender) throws CommandException {
List<Task<?>> tasks = WorldGuard.getInstance().getSupervisor().getTasks();
if (tasks.isEmpty()) {
sender.print("There are currently no running tasks.");
} else {
tasks.sort(new TaskStateComparator());
MessageBox builder = new MessageBox("Running Tasks", new TextComponentProducer());
builder.append(TextComponent.of("Note: Some 'running' tasks may be waiting to be start.", TextColor.GRAY));
for (Task<?> task : tasks) {
builder.append(TextComponent.newline());
builder.append(TextComponent.of("(" + task.getState().name() + ") ", TextColor.BLUE));
builder.append(TextComponent.of(CommandUtils.getOwnerName(task.getOwner()) + ": ", TextColor.YELLOW));
builder.append(TextComponent.of(task.getName(), TextColor.WHITE));
}
sender.print(builder.create());
}
}
Aggregations