Skip to content

Commit

Permalink
fix some tasks queuing notifications while disabled (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyfts authored Oct 2, 2024
1 parent 265b6c3 commit 4150f04
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/main/java/serverutils/lib/data/Universe.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ public void scheduleTask(Task task) {
public void scheduleTask(Task task, boolean condition) {
if (!condition) return;
if (task.getNextTime() <= -1) return;
task.queueNotifications(this);
taskQueue.add(task);
}

Expand Down
4 changes: 1 addition & 3 deletions src/main/java/serverutils/task/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ public Task(long whenToRun, Ticks ticks, boolean repeatable) {
this.interval = getTimeType() == TimeType.MILLIS ? ticks.millis() : ticks.ticks();
this.nextTime = whenToRun + interval;
this.repeatable = repeatable;

queueNotifications(Universe.get());
}

public abstract void execute(Universe universe);
Expand All @@ -51,7 +49,7 @@ public void setNextTime(long time) {
queueNotifications(Universe.get());
}

private void queueNotifications(Universe universe) {
public void queueNotifications(Universe universe) {
List<NotifyTask> notifications = getNotifications();
if (notifications == null || notifications.isEmpty()) return;
getNotifications().forEach(universe::scheduleTask);
Expand Down

0 comments on commit 4150f04

Please sign in to comment.