From 93a1bc6e5c42590c6f918dfb3d1a674e7bb4eac4 Mon Sep 17 00:00:00 2001 From: Aram Date: Fri, 25 Oct 2024 15:33:28 +0200 Subject: [PATCH] Ported the SCHEDULAR Fix to 1.20 (#58) ## Description Ensured that the SCHEDULAR is being restarted when you join a world to ensure it is always online. ## Changes - **Change 1**: Ensured that the SCHEDULAR is being restarted when you join a world ## How has this been tested? * Join a world * Save and Leave * Rejoin and see if the SCHEDULAR is still active ## Screenshots (if applicable) ## Type of Change - [x] Bug fix - [ ] New feature - [ ] Documentation update ## Checklist - [x] My code follows the style guidelines of this project. [Contributing](https://github.com/MeAlam1/BlueLib/blob/1.21/CONTRIBUTING.md) - [x] I have performed a self-review of my own code. - [x] I have commented my code following the guidelines. [Contributing](https://github.com/MeAlam1/BlueLib/blob/1.21/CONTRIBUTING.md) - [x] My changes generate no new warnings. ## Related Issues * Got the issue through Discord --------- Co-Authored-By: Bluedude <68448043+Dan6335@users.noreply.github.com> --- common/src/main/java/software/bluelib/BlueLibConstants.java | 4 ++-- .../java/software/bluelib/example/event/ReloadHandler.java | 2 ++ .../java/software/bluelib/example/event/ReloadHandler.java | 2 ++ .../java/software/bluelib/example/event/ReloadHandler.java | 2 ++ 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/software/bluelib/BlueLibConstants.java b/common/src/main/java/software/bluelib/BlueLibConstants.java index 0950db7a..2e7d01d0 100644 --- a/common/src/main/java/software/bluelib/BlueLibConstants.java +++ b/common/src/main/java/software/bluelib/BlueLibConstants.java @@ -45,14 +45,14 @@ private BlueLibConstants() { public static final Logger LOGGER = Logger.getLogger(BlueLibConstants.MOD_NAME); /** - * A {@code public static final} {@link ScheduledExecutorService} used to schedule tasks, such as printing messages after a delay. + * A {@code public static} {@link ScheduledExecutorService} used to schedule tasks, such as printing messages after a delay. *

* This executor runs tasks on a single thread to ensure delayed tasks run in a separate thread from the main thread. *

* * @since 1.0.0 */ - public static final ScheduledExecutorService SCHEDULER = Executors.newScheduledThreadPool(1); + public static ScheduledExecutorService SCHEDULER = Executors.newScheduledThreadPool(1); /** * A {@code public static final} {@link String} representing the Mod ID for the {@code BlueLib} mod. diff --git a/fabric/src/main/java/software/bluelib/example/event/ReloadHandler.java b/fabric/src/main/java/software/bluelib/example/event/ReloadHandler.java index b96a2d0c..56c69e4a 100644 --- a/fabric/src/main/java/software/bluelib/example/event/ReloadHandler.java +++ b/fabric/src/main/java/software/bluelib/example/event/ReloadHandler.java @@ -11,6 +11,7 @@ import java.util.Arrays; import java.util.List; +import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; /** @@ -50,6 +51,7 @@ public class ReloadHandler extends ReloadEventHandler { * @since 1.0.0 */ public static void onServerStart(MinecraftServer pServer) { + BlueLibConstants.SCHEDULER = new ScheduledThreadPoolExecutor(1); server = pServer; ReloadHandler.LoadEntityVariants(server); BaseLogger.log(BaseLogLevel.INFO, "Entity variants loaded.", true); diff --git a/forge/src/main/java/software/bluelib/example/event/ReloadHandler.java b/forge/src/main/java/software/bluelib/example/event/ReloadHandler.java index 56fe6112..b5285d6c 100644 --- a/forge/src/main/java/software/bluelib/example/event/ReloadHandler.java +++ b/forge/src/main/java/software/bluelib/example/event/ReloadHandler.java @@ -13,6 +13,7 @@ import java.util.Arrays; import java.util.List; +import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; /** @@ -53,6 +54,7 @@ public class ReloadHandler extends ReloadEventHandler { */ @SubscribeEvent public static void onServerStart(ServerStartingEvent pEvent) { + BlueLibConstants.SCHEDULER = new ScheduledThreadPoolExecutor(1); server = pEvent.getServer(); ReloadHandler.LoadEntityVariants(server); BaseLogger.log(BaseLogLevel.INFO, "Entity variants loaded.", true); diff --git a/neoforge/src/main/java/software/bluelib/example/event/ReloadHandler.java b/neoforge/src/main/java/software/bluelib/example/event/ReloadHandler.java index e3a4f73d..05650602 100644 --- a/neoforge/src/main/java/software/bluelib/example/event/ReloadHandler.java +++ b/neoforge/src/main/java/software/bluelib/example/event/ReloadHandler.java @@ -14,6 +14,7 @@ import java.util.Arrays; import java.util.List; +import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; /** @@ -56,6 +57,7 @@ public class ReloadHandler extends ReloadEventHandler { */ @SubscribeEvent public static void onServerStart(ServerStartingEvent pEvent) { + BlueLibConstants.SCHEDULER = new ScheduledThreadPoolExecutor(1); server = pEvent.getServer(); ReloadHandler.LoadEntityVariants(server); BaseLogger.log(BaseLogLevel.INFO, "Entity variants loaded.", true);