aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java
diff options
context:
space:
mode:
authorWyvest <45589059+Wyvest@users.noreply.github.com>2022-05-28 12:02:04 +0700
committerGitHub <noreply@github.com>2022-05-28 12:02:04 +0700
commit01e4c0dfb2a9726a9bf1c4d1a1fe28edbc3d094c (patch)
tree2949a7d1a9e6a5e9fbf6db983491ab813614b889 /src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java
parent2f45fed981d7fcdf6e39791fecfa1dd410614fbf (diff)
downloadOneConfig-01e4c0dfb2a9726a9bf1c4d1a1fe28edbc3d094c.tar.gz
OneConfig-01e4c0dfb2a9726a9bf1c4d1a1fe28edbc3d094c.tar.bz2
OneConfig-01e4c0dfb2a9726a9bf1c4d1a1fe28edbc3d094c.zip
OC-32 OC-34 (#24)
* OC-34 hypixel utils class (#21) * OC-26 Build Workflow * OC-26 oops * OC-33 some networking utils * OC-34 idk * OC-34 idk * OC-34 restructure hypixel utils * hypixelutils and multithreading implement more events remove vcal icon stuff * more javadocs Co-authored-by: Ethan <git@ethanlibs.co>
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java b/src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java
index 2fa2017..35b7b8b 100644
--- a/src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java
+++ b/src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java
@@ -5,23 +5,26 @@ import cc.polyfrost.oneconfig.events.event.Stage;
import cc.polyfrost.oneconfig.events.event.TickEvent;
import cc.polyfrost.oneconfig.libs.eventbus.Subscribe;
+/**
+ * Schedules a Runnable to be called after a certain amount of ticks.
+ */
public class TickDelay {
private int delay;
private final Runnable function;
public TickDelay(Runnable functionName, int ticks) {
- EventManager.INSTANCE.getEventBus().register(this);
+ EventManager.INSTANCE.register(this);
delay = ticks;
function = functionName;
}
@Subscribe
- public void onTick(TickEvent event) {
+ protected void onTick(TickEvent event) {
if (event.stage == Stage.START) {
// Delay expired
if (delay < 1) {
function.run();
- EventManager.INSTANCE.getEventBus().unregister(this);
+ EventManager.INSTANCE.unregister(this);
}
delay--;
}