aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-06-16 18:54:26 +0200
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-06-16 18:54:26 +0200
commit4db4afb9156edfd7d5485f80e18739d205e23d27 (patch)
tree41f5225f9b542c3374a1bc897710243aa3278326 /src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java
parent7cf9731db5f34c8a413746161957e0e094e2374d (diff)
parent416b60ef717f4f7183f54a4a7362e0c540928c8d (diff)
downloadOneConfig-4db4afb9156edfd7d5485f80e18739d205e23d27.tar.gz
OneConfig-4db4afb9156edfd7d5485f80e18739d205e23d27.tar.bz2
OneConfig-4db4afb9156edfd7d5485f80e18739d205e23d27.zip
Merge branch 'master' of github.com:Polyfrost/OneConfig
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java b/src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java
index b51ee85..b7ee2c8 100644
--- a/src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java
+++ b/src/main/java/cc/polyfrost/oneconfig/utils/TickDelay.java
@@ -7,14 +7,20 @@ import cc.polyfrost.oneconfig.libs.eventbus.Subscribe;
/**
* Schedules a Runnable to be called after a certain amount of ticks.
+ *
+ * If the amount of ticks is below 1, the Runnable will be called immediately.
*/
public class TickDelay {
private final Runnable function;
private int delay;
public TickDelay(Runnable functionName, int ticks) {
- EventManager.INSTANCE.register(this);
- delay = ticks;
+ if (ticks < 1) {
+ functionName.run();
+ } else {
+ EventManager.INSTANCE.register(this);
+ delay = ticks;
+ }
function = functionName;
}