aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/xmrvizzy/skyblocker/utils/Scheduler.java
diff options
context:
space:
mode:
authorKevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>2023-05-22 20:30:12 -0400
committerKevinthegreat <92656833+kevinthegreat1@users.noreply.github.com>2023-05-26 16:34:47 -0400
commit049f988c904e7bee85e4d0a03e2dbbcf0047d27e (patch)
treea530446b7a7f74219a1649c76d63148b785ffead /src/main/java/me/xmrvizzy/skyblocker/utils/Scheduler.java
parentd467fab0a81541d5518728edf1028fa2f2dd3e54 (diff)
downloadSkyblocker-049f988c904e7bee85e4d0a03e2dbbcf0047d27e.tar.gz
Skyblocker-049f988c904e7bee85e4d0a03e2dbbcf0047d27e.tar.bz2
Skyblocker-049f988c904e7bee85e4d0a03e2dbbcf0047d27e.zip
Add Livid Color
Diffstat (limited to 'src/main/java/me/xmrvizzy/skyblocker/utils/Scheduler.java')
-rw-r--r--src/main/java/me/xmrvizzy/skyblocker/utils/Scheduler.java13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/Scheduler.java b/src/main/java/me/xmrvizzy/skyblocker/utils/Scheduler.java
index efba4995..09db3f93 100644
--- a/src/main/java/me/xmrvizzy/skyblocker/utils/Scheduler.java
+++ b/src/main/java/me/xmrvizzy/skyblocker/utils/Scheduler.java
@@ -12,7 +12,7 @@ import java.util.PriorityQueue;
public class Scheduler {
private static final Logger LOGGER = LoggerFactory.getLogger(Scheduler.class);
private int currentTick;
- private final PriorityQueue<ScheduledTask> tasks;
+ protected final PriorityQueue<ScheduledTask> tasks;
/**
* Do not instantiate this class. Use {@link SkyblockerMod#scheduler} instead.
@@ -52,17 +52,20 @@ public class Scheduler {
currentTick += 1;
ScheduledTask task;
while ((task = tasks.peek()) != null && task.schedule <= currentTick) {
- tasks.poll();
- task.run();
+ runTask(tasks.poll());
}
}
+ protected void runTask(Runnable task){
+ task.run();
+ }
+
/**
* A task that runs every period ticks. More specifically, this task reschedules itself to run again after period ticks every time it runs.
* @param inner the task to run
* @param period the period in ticks
*/
- private record CyclicTask(Runnable inner, int period) implements Runnable {
+ protected record CyclicTask(Runnable inner, int period) implements Runnable {
@Override
public void run() {
SkyblockerMod.getInstance().scheduler.schedule(this, period);
@@ -75,7 +78,7 @@ public class Scheduler {
* @param inner the task to run
* @param schedule the tick to run at
*/
- private record ScheduledTask(Runnable inner, int schedule) implements Comparable<ScheduledTask>, Runnable {
+ protected record ScheduledTask(Runnable inner, int schedule) implements Comparable<ScheduledTask>, Runnable {
@Override
public int compareTo(ScheduledTask o) {
return schedule - o.schedule;