Search in sources :

Example 1 with Delayable

use of net.aufdemrand.denizencore.scripts.queues.core.Delayable in project Denizen-For-Bukkit by DenizenScript.

the class QueueCommand method execute.

@Override
public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
    ScriptQueue queue = (ScriptQueue) scriptEntry.getObject("queue");
    Action action = (Action) scriptEntry.getObject("action");
    Duration delay = (Duration) scriptEntry.getObject("delay");
    // Debugger
    dB.report(scriptEntry, getName(), queue.debug() + aH.debugObj("Action", action.toString()) + (action == Action.DELAY ? delay.debug() : ""));
    switch(action) {
        case CLEAR:
            queue.clear();
            return;
        case STOP:
            queue.clear();
            queue.stop();
            return;
        case PAUSE:
            if (queue instanceof Delayable) {
                ((Delayable) queue).setPaused(true);
            } else {
                queue.forceToTimed(new Duration(1L)).setPaused(true);
            }
            return;
        case RESUME:
            if (queue instanceof Delayable) {
                ((Delayable) queue).setPaused(false);
            }
            return;
        case DELAY:
            if (queue instanceof Delayable) {
                ((Delayable) queue).delayFor(delay);
            } else {
                queue.forceToTimed(delay);
            }
            return;
    }
}
Also used : Duration(net.aufdemrand.denizencore.objects.Duration) Delayable(net.aufdemrand.denizencore.scripts.queues.core.Delayable) ScriptQueue(net.aufdemrand.denizencore.scripts.queues.ScriptQueue)

Example 2 with Delayable

use of net.aufdemrand.denizencore.scripts.queues.core.Delayable in project Denizen-For-Bukkit by DenizenScript.

the class WaitCommand method execute.

@Override
public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
    ScriptQueue queue = (ScriptQueue) scriptEntry.getObject("queue");
    Duration delay = (Duration) scriptEntry.getObject("delay");
    dB.report(scriptEntry, getName(), aH.debugObj("queue", queue.id) + delay.debug());
    // Tell the queue to delay
    if (queue instanceof Delayable) {
        ((Delayable) queue).delayFor(delay);
    } else {
        scriptEntry.setInstant(false);
        dB.echoDebug(scriptEntry, "Forcing queue " + queue.id + " into a timed queue...");
        queue.forceToTimed(delay);
    }
}
Also used : Duration(net.aufdemrand.denizencore.objects.Duration) Delayable(net.aufdemrand.denizencore.scripts.queues.core.Delayable) ScriptQueue(net.aufdemrand.denizencore.scripts.queues.ScriptQueue)

Aggregations

Duration (net.aufdemrand.denizencore.objects.Duration)2 ScriptQueue (net.aufdemrand.denizencore.scripts.queues.ScriptQueue)2 Delayable (net.aufdemrand.denizencore.scripts.queues.core.Delayable)2