Skip to content

Commit 12ec270

Browse files
committed
fix: AsyncRecipeChoiceTask logic error
1 parent 81943cf commit 12ec270

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AsyncRecipeChoiceTask.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.github.thebusybiscuit.slimefun4.implementation.tasks;
22

3+
import com.tcoded.folialib.wrapper.task.WrappedTask;
34
import io.github.bakedlibs.dough.collections.LoopIterator;
45
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
56
import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
@@ -34,6 +35,7 @@ public class AsyncRecipeChoiceTask implements Runnable {
3435
private final ReadWriteLock lock = new ReentrantReadWriteLock();
3536

3637
private Inventory inventory;
38+
private WrappedTask task;
3739

3840
/**
3941
* This will start this task for the given {@link Inventory}.
@@ -45,6 +47,7 @@ public void start(@Nonnull Inventory inv) {
4547
Validate.notNull(inv, "Inventory must not be null");
4648

4749
inventory = inv;
50+
task = Slimefun.getFoliaLib().getScheduler().runTimerAsync(this, 1, UPDATE_INTERVAL);
4851
}
4952

5053
public void add(int slot, @Nonnull MaterialChoice choice) {
@@ -104,9 +107,7 @@ public void clear() {
104107
public void run() {
105108
// Terminate the task when noone is viewing the Inventory
106109
if (inventory.getViewers().isEmpty()) {
107-
Slimefun.getFoliaLib()
108-
.getScheduler()
109-
.cancelTask(Slimefun.getFoliaLib().getScheduler().runTimerAsync(this, 1, UPDATE_INTERVAL));
110+
Slimefun.getFoliaLib().getScheduler().cancelTask(task);
110111
return;
111112
}
112113

src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/player/AbstractPlayerTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@ protected boolean isValid() {
5656
}
5757

5858
protected abstract void executeTask();
59-
}
59+
}

0 commit comments

Comments
 (0)