11 Commits
Author SHA1 Message Date
NotAlexNoyle 87b7c3d8f0 Exclude CODEOWNERS from language statistics 2026-11-02 16:32:56 -05:00
NotAlexNoyle 0133b2f0c5 Add CODEOWNERS (one staff approval) 2026-11-02 16:32:56 -05:00
NotCoded 99533d1a7a Revert "port to 1.20.6"
This reverts commit 581359324a.
2024-07-08 20:35:15 +02:00
Infinityy 581359324a port to 1.20.6 2024-07-08 20:30:17 +02:00
Blumbo cb6d19455e change group id 2023-07-13 18:17:39 +03:00
Blumbo b40649fa71 Documentation improvements 2023-07-06 14:24:44 +03:00
Blumbo 04d7e96d79 Correct access modifier 2023-07-05 20:41:01 +03:00
Blumbo d5bedb3797 Actually cancel tasks that are cancelled outside task run method 2023-07-05 20:34:21 +03:00
Blumbo f151ac18fa allow client environment as well 2023-07-04 21:06:04 +03:00
Blumbo 2306b1e55d Merge remote-tracking branch 'origin/master' 2023-07-03 23:58:45 +03:00
Blumbo 23c196c673 Some documentation 2023-07-03 23:58:36 +03:00
11 changed files with 49 additions and 25 deletions

No files matched your search

+1
View File
@@ -0,0 +1 @@
.gitea/CODEOWNERS linguist-detectable=false
+3
View File
@@ -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
View File
@@ -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;
}
}
@@ -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,4 +1,4 @@
package net.blumbo.blfscheduler;
package io.github.blumbo.blfscheduler;
public class BlfSchedulerTicker {
@@ -1,4 +1,4 @@
package net.blumbo.blfscheduler;
package io.github.blumbo.blfscheduler;
@FunctionalInterface
interface BlfTask {
@@ -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 -1
View File
@@ -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"
+2 -2
View File
@@ -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": [