Search in sources :

Example 1 with CommandTask

use of com.mcsimonflash.sponge.cmdscheduler.task.CommandTask in project CmdScheduler by SimonFlash.

the class Stop method execute.

@Override
public CommandResult execute(CommandSource src, CommandContext args) {
    CommandTask task = args.<CommandTask>getOne("task").get();
    task.getTask().stop(CmdScheduler.get().getContainer());
    src.sendMessage(Text.of("Successfully stopped task " + task.getName() + "."));
    return CommandResult.success();
}
Also used : CommandTask(com.mcsimonflash.sponge.cmdscheduler.task.CommandTask)

Example 2 with CommandTask

use of com.mcsimonflash.sponge.cmdscheduler.task.CommandTask in project CmdScheduler by SimonFlash.

the class Config method loadTask.

public static void loadTask(ConfigurationNode node) {
    try {
        String name = (String) node.getKey();
        String command = node.getNode("command").getString("");
        Schedule schedule = getSchedule(node.getNode("schedule"));
        Tristate async = node.getNode("async").isVirtual() ? Tristate.UNDEFINED : Tristate.fromBoolean(node.getNode("async").getBoolean(false));
        tasks.put(name.toLowerCase(), new CommandTask(name, command.startsWith("/") ? command.substring(1) : command, schedule, async));
    } catch (IllegalArgumentException e) {
        CmdScheduler.get().getLogger().error(e.getMessage());
    }
}
Also used : CommandTask(com.mcsimonflash.sponge.cmdscheduler.task.CommandTask) Tristate(org.spongepowered.api.util.Tristate)

Example 3 with CommandTask

use of com.mcsimonflash.sponge.cmdscheduler.task.CommandTask in project CmdScheduler by SimonFlash.

the class Execute method execute.

@Override
public CommandResult execute(CommandSource src, CommandContext args) {
    CommandTask task = args.<CommandTask>getOne("task").get();
    task.getTask().execute(CmdScheduler.get().getContainer());
    src.sendMessage(Text.of("Successfully executed task " + task.getName() + "."));
    return CommandResult.success();
}
Also used : CommandTask(com.mcsimonflash.sponge.cmdscheduler.task.CommandTask)

Example 4 with CommandTask

use of com.mcsimonflash.sponge.cmdscheduler.task.CommandTask in project CmdScheduler by SimonFlash.

the class Start method execute.

@Override
public CommandResult execute(CommandSource src, CommandContext args) {
    CommandTask task = args.<CommandTask>getOne("task").get();
    task.getTask().start(CmdScheduler.get().getContainer());
    src.sendMessage(Text.of("Successfully started task " + task.getName() + "."));
    return CommandResult.success();
}
Also used : CommandTask(com.mcsimonflash.sponge.cmdscheduler.task.CommandTask)

Example 5 with CommandTask

use of com.mcsimonflash.sponge.cmdscheduler.task.CommandTask in project CmdScheduler by SimonFlash.

the class Delete method execute.

@Override
public CommandResult execute(CommandSource src, CommandContext args) {
    CommandTask task = args.<CommandTask>getOne("task").get();
    task.getTask().stop(CmdScheduler.get().getContainer());
    Config.tasks.remove(task.getName().toLowerCase());
    src.sendMessage(Text.of("Deleted task " + task.getName() + ". If this task was defined in the config, it must be removed manually."));
    return CommandResult.success();
}
Also used : CommandTask(com.mcsimonflash.sponge.cmdscheduler.task.CommandTask)

Aggregations

CommandTask (com.mcsimonflash.sponge.cmdscheduler.task.CommandTask)6 Tristate (org.spongepowered.api.util.Tristate)2 CommandException (org.spongepowered.api.command.CommandException)1