/*
 * This file is part of PV-Star for Bukkit, licensed under the MIT License (MIT).
 *
 * Copyright (c) JCThePants (www.jcwhatever.com)
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.jcwhatever.bukkit.pvs.scripting;

import com.jcwhatever.nucleus.utils.scheduler.ScheduledTask;
import com.jcwhatever.nucleus.scripting.api.IScriptApiObject;
import com.jcwhatever.bukkit.pvs.api.arena.Arena;
import com.jcwhatever.bukkit.pvs.api.utils.ArenaScheduler;

/**
 * Script API to give access to the scheduler.
 */
public class ArenaSchedulerApiObject implements IScriptApiObject {

    private final Arena _arena;

    /**
     * Constructor.
     */
    ArenaSchedulerApiObject(Arena arena) {
        _arena = arena;
    }

    @Override
    public boolean isDisposed() {
        return false;
    }

    /**
     * Reset api and release resources.
     */
    @Override
    public void dispose() {
        // do nothing
    }

    /**
     * Run a task later. Task will run if arena is not running but will be cancelled
     * when the arena ends.
     *
     * @param delayTicks  Delay in ticks before executing the task
     * @param runnable    The task to run
     *
     * @return {@link ScheduledTask}
     */
    public ScheduledTask runTaskLater(int delayTicks, Runnable runnable) {
        return ArenaScheduler.runTaskLater(_arena, delayTicks, runnable);
    }

    /**
     * Repeat a task at interval. Task will NOT run unless the arena is running. Task
     * is cancelled when the arena ends.
     *
     * @param initialDelay  The initial delay in ticks before running the first task
     * @param interval      The delay in ticks between tasks
     * @param runnable      The task to run
     *
     * @return {@link ScheduledTask}
     */
    public ScheduledTask runTaskRepeat(int initialDelay, int interval, Runnable runnable) {
        return ArenaScheduler.runTaskRepeat(_arena, initialDelay, interval, runnable);
    }
}

@@ -1282,40 +1282,92 @@
 ver.
-nucleus.utils.scheduler.
+bukkit.pvs.api.arena.Arena;%0Aimport com.jcwhatever.bukkit.pvs.api.utils.Arena
 Schedule
 dTas
@@ -1362,21 +1362,17 @@
 Schedule
-dTask
+r
 ;%0Aimport
@@ -1453,92 +1453,41 @@
 ver.
-bukkit.pvs.api.arena.Arena;%0Aimport com.jcwhatever.bukkit.pvs.api.utils.Arena
+nucleus.utils.scheduler.I
 Schedule
 r;%0A%0A
@@ -1482,17 +1482,21 @@
 Schedule
-r
+dTask
 ;%0A%0A/**%0A 
@@ -2218,32 +2218,33 @@
  @return %7B@link 
+I
 ScheduledTask%7D%0A 
@@ -2253,32 +2253,33 @@
   */%0A    public 
+I
 ScheduledTask ru
@@ -2768,16 +2768,17 @@
  %7B@link 
+I
 Schedule
@@ -2803,16 +2803,17 @@
  public 
+I
 Schedule

use interfaces for task scheduler