Compare commits
11
Commits
1.16_combat-6
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
87b7c3d8f0
|
||
|
|
0133b2f0c5
|
||
|
|
99533d1a7a | ||
|
|
581359324a | ||
|
|
cb6d19455e | ||
|
|
b40649fa71 | ||
|
|
04d7e96d79 | ||
|
|
d5bedb3797 | ||
|
|
f151ac18fa | ||
|
|
2306b1e55d | ||
|
|
23c196c673 |
No files matched your search
@@ -0,0 +1 @@
|
||||
.gitea/CODEOWNERS linguist-detectable=false
|
||||
@@ -0,0 +1,3 @@
|
||||
# Pull requests request review from the eligible staff team(s).
|
||||
# One approval from either an Admin or Developer satisfies branch protection.
|
||||
* @trueog/Admins @trueog/Developers
|
||||
+2
-2
@@ -8,6 +8,6 @@ yarn_mappings=1.20.1+build.2
|
||||
loader_version=0.14.21
|
||||
|
||||
# Mod Properties
|
||||
mod_version=1.0.0
|
||||
maven_group=net.blumbo
|
||||
mod_version=1.0.3
|
||||
maven_group=io.github.blumbo
|
||||
archives_base_name=blf-scheduler
|
||||
@@ -0,0 +1,16 @@
|
||||
package io.github.blumbo.blfscheduler;
|
||||
|
||||
public abstract class BlfRunnable implements BlfTask {
|
||||
|
||||
boolean isCancelled;
|
||||
boolean isRepeating;
|
||||
long period;
|
||||
|
||||
/**
|
||||
* Stops the delayed or repeating task from running next time.
|
||||
*/
|
||||
public void cancel() {
|
||||
this.isCancelled = true;
|
||||
}
|
||||
|
||||
}
|
||||
+20
-4
@@ -1,4 +1,4 @@
|
||||
package net.blumbo.blfscheduler;
|
||||
package io.github.blumbo.blfscheduler;
|
||||
|
||||
import com.mojang.logging.LogUtils;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
@@ -19,10 +19,17 @@ public class BlfScheduler implements ModInitializer {
|
||||
@Override
|
||||
public void onInitialize() {}
|
||||
|
||||
/**
|
||||
* Runs a task after specified amount of ticks.
|
||||
* @param delay Number of ticks before the task is run. Should be at least 0.
|
||||
* @param runnable Task being run.
|
||||
* @return Runnable specified as parameter.
|
||||
*/
|
||||
public static BlfRunnable delay(long delay, @NotNull BlfRunnable runnable) {
|
||||
delay = properDelayCheck(delay);
|
||||
|
||||
runnable.cancelled = true;
|
||||
runnable.isCancelled = false;
|
||||
runnable.isRepeating = false;
|
||||
runnable.period = Integer.MAX_VALUE;
|
||||
|
||||
long time = ticks + delay;
|
||||
@@ -31,10 +38,18 @@ public class BlfScheduler implements ModInitializer {
|
||||
return runnable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Repeats a task every specified amount of ticks.
|
||||
* @param delay Number of ticks before the first task is run. Should be at least 0.
|
||||
* @param period Number of ticks between following runs. Should be at least 1.
|
||||
* @param runnable Task being repeated.
|
||||
* @return Runnable specified as parameter.
|
||||
*/
|
||||
public static BlfRunnable repeat(long delay, long period, @NotNull BlfRunnable runnable) {
|
||||
delay = properDelayCheck(delay);
|
||||
|
||||
runnable.cancelled = false;
|
||||
runnable.isCancelled = false;
|
||||
runnable.isRepeating = true;
|
||||
runnable.period = period;
|
||||
|
||||
long time = ticks + delay;
|
||||
@@ -54,8 +69,9 @@ public class BlfScheduler implements ModInitializer {
|
||||
}
|
||||
|
||||
private static void runCurrentTimeTask(BlfRunnable runnable) {
|
||||
if (runnable.isCancelled) return;
|
||||
runnable.run();
|
||||
if (runnable.cancelled) return;
|
||||
if (runnable.isCancelled || !runnable.isRepeating) return;
|
||||
|
||||
Long period = properPeriodCheck(runnable.period);
|
||||
if (period == null) return;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package net.blumbo.blfscheduler;
|
||||
package io.github.blumbo.blfscheduler;
|
||||
|
||||
public class BlfSchedulerTicker {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package net.blumbo.blfscheduler;
|
||||
package io.github.blumbo.blfscheduler;
|
||||
|
||||
@FunctionalInterface
|
||||
interface BlfTask {
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package net.blumbo.blfscheduler.mixin;
|
||||
package io.github.blumbo.blfscheduler.mixin;
|
||||
|
||||
import net.blumbo.blfscheduler.BlfSchedulerTicker;
|
||||
import io.github.blumbo.blfscheduler.BlfSchedulerTicker;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
@@ -1,12 +0,0 @@
|
||||
package net.blumbo.blfscheduler;
|
||||
|
||||
public abstract class BlfRunnable implements BlfTask {
|
||||
|
||||
protected boolean cancelled;
|
||||
protected long period;
|
||||
|
||||
public void cancel() {
|
||||
this.cancelled = true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "net.blumbo.blfscheduler.mixin",
|
||||
"package": "io.github.blumbo.blfscheduler.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"mixins": [
|
||||
"MinecraftServerMixin"
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
"authors": [],
|
||||
"contact": {},
|
||||
"license": "LGPL-3.0",
|
||||
"environment": "server",
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"main": [
|
||||
"net.blumbo.blfscheduler.BlfScheduler"
|
||||
"io.github.blumbo.blfscheduler.BlfScheduler"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
|
||||
Reference in new issue
Block a user