diff --git a/gradle.properties b/gradle.properties index caf375d..344cdc3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ yarn_mappings=1.20.1+build.10 loader_version=0.16.7 # Mod Properties -mod_version=1.16.0 +mod_version=1.16.1 maven_group=cc.reconnected archives_base_name=rcc-server diff --git a/src/main/java/cc/reconnected/server/api/events/RestartEvents.java b/src/main/java/cc/reconnected/server/api/events/RestartEvents.java new file mode 100644 index 0000000..b0c1081 --- /dev/null +++ b/src/main/java/cc/reconnected/server/api/events/RestartEvents.java @@ -0,0 +1,31 @@ +package cc.reconnected.server.api.events; + +import cc.reconnected.server.core.BossBarManager; +import net.fabricmc.fabric.api.event.Event; +import net.fabricmc.fabric.api.event.EventFactory; + +public class RestartEvents { + public static final Event SCHEDULED = EventFactory.createArrayBacked(Schedule.class, callbacks -> + (timeBar) -> { + for (Schedule callback : callbacks) { + callback.onSchedule(timeBar); + } + }); + + public static final Event CANCELED = EventFactory.createArrayBacked(Cancel.class, callbacks -> + (timeBar) -> { + for (Cancel callback : callbacks) { + callback.onCancel(timeBar); + } + }); + + @FunctionalInterface + public interface Schedule { + void onSchedule(BossBarManager.TimeBar timeBar); + } + + @FunctionalInterface + public interface Cancel { + void onCancel(BossBarManager.TimeBar timeBar); + } +} diff --git a/src/main/java/cc/reconnected/server/core/AutoRestart.java b/src/main/java/cc/reconnected/server/core/AutoRestart.java index ef6f01b..a5c703b 100644 --- a/src/main/java/cc/reconnected/server/core/AutoRestart.java +++ b/src/main/java/cc/reconnected/server/core/AutoRestart.java @@ -3,6 +3,7 @@ package cc.reconnected.server.core; import cc.reconnected.server.RccServer; import cc.reconnected.server.api.events.BossBarEvents; import cc.reconnected.server.api.events.RccEvents; +import cc.reconnected.server.api.events.RestartEvents; import cc.reconnected.server.util.Components; import net.kyori.adventure.key.InvalidKeyException; import net.kyori.adventure.key.Key; @@ -90,6 +91,8 @@ public class AutoRestart { BossBar.Style.NOTCHED_20, true ); + + RestartEvents.SCHEDULED.invoker().onSchedule(restartBar); } public static boolean isScheduled() { @@ -99,6 +102,7 @@ public class AutoRestart { public static void cancel() { if (restartBar != null) { BossBarManager.getInstance().cancelTimeBar(restartBar); + RestartEvents.CANCELED.invoker().onCancel(restartBar); restartBar = null; }