Skip to content

Commit

Permalink
feat(minecraft/scheduler): add isCancelled and getTaskId methods to S…
Browse files Browse the repository at this point in the history
…chedulerTask interface and implementations

This commit adds two new methods to the SchedulerTask interface and its
implementations: MinecraftFoliaScheduler and MinecraftBukkitScheduler.
The isCancelled method returns true if the task has been cancelled, and
the getTaskId method returns the unique id of the task.
FoliaMC does not provide a task id.
  • Loading branch information
GeorgeV220 committed Dec 27, 2023
1 parent 9eb4f8f commit a293366
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
package com.georgev22.library.minecraft.scheduler;

import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitTask;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;

@ApiStatus.NonExtendable
public class MinecraftBukkitScheduler implements MinecraftScheduler {
Expand Down Expand Up @@ -123,5 +119,15 @@ public BukkitSchedulerTask(BukkitTask bukkitTask) {
public void cancel() {
bukkitTask.cancel();
}

@Override
public boolean isCancelled() {
return bukkitTask.isCancelled();
}

@Override
public int getTaskId() {
return bukkitTask.getTaskId();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -206,5 +206,15 @@ public FoliaSchedulerTask(ScheduledTask scheduledTask) {
public void cancel() {
scheduledTask.cancel();
}

@Override
public boolean isCancelled() {
return scheduledTask.isCancelled();
}

@Override
public int getTaskId() {
return 0;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@ public interface SchedulerTask {

void cancel();

boolean isCancelled();

int getTaskId();

}

0 comments on commit a293366

Please sign in to comment.