smartcmd-MinecraftConsoles/Minecraft.Server.FourKit/Scheduler/FourKitTask.cs
DrPerkyLegit 76270d7f3c
FourKitScheduler & FourKitTask (#17)
* scheduler

* add docs + make cancel public lol

---------

Co-authored-by: sylvessa <225480449+sylvessa@users.noreply.github.com>
2026-05-06 17:36:47 -05:00

52 lines
1.7 KiB
C#

using Minecraft.Server.FourKit.Plugin;
using System;
using System.Collections.Generic;
using System.Text;
namespace Minecraft.Server.FourKit.Scheduler
{
public class FourKitTask
{
private ServerPlugin owner;
private int taskId;
internal bool shouldRun = true;
internal int startDelay;
internal int runCooldown;
internal int lastRunTick = -1;
internal bool startedRunning = false;
/// <summary>
/// Initializes a new task instance with owner, task id, start delay, and run cooldown.
/// </summary>
/// <param name="owner">The plugin that owns this task.</param>
/// <param name="taskId">Task id number.</param>
/// <param name="startDelay">Delay in server ticks before executing the task.</param>
/// <param name="runCooldown">Period in server ticks between runs, or -1 for one-shot tasks.</param>
internal FourKitTask(ServerPlugin owner, int taskId, int startDelay, int runCooldown)
{
this.owner = owner;
this.taskId = taskId;
this.startDelay = startDelay;
this.runCooldown = runCooldown;
}
/// <summary>
/// Will attempt to cancel this task.
/// </summary>
public void cancel() { shouldRun = false; }
/// <summary>
/// Returns the Plugin that owns this task.
/// </summary>
/// <returns>The Plugin that owns the task.</returns>
public ServerPlugin getOwner() { return owner; }
/// <summary>
/// Returns the taskId for the task.
/// </summary>
/// <returns>Task id number.</returns>
public int getTaskId() { return taskId; }
}
}