From 063dd72158e56dfc83be456e3f6eefe202fe1b74 Mon Sep 17 00:00:00 2001 From: leelawd Date: Sat, 31 Mar 2018 13:51:30 +0100 Subject: [PATCH] Add configurable delay timer for loading chunk loaders at startup --- .../betterchunkloader/BetterChunkLoader.java | 15 +++++++++------ .../betterchunkloader/config/CoreConfig.java | 3 +++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/java/net/moddedminecraft/betterchunkloader/BetterChunkLoader.java b/src/main/java/net/moddedminecraft/betterchunkloader/BetterChunkLoader.java index d2a2ff8..d804f36 100644 --- a/src/main/java/net/moddedminecraft/betterchunkloader/BetterChunkLoader.java +++ b/src/main/java/net/moddedminecraft/betterchunkloader/BetterChunkLoader.java @@ -36,6 +36,7 @@ import java.io.IOException; import java.nio.file.Path; import java.util.*; +import java.util.concurrent.TimeUnit; @Plugin( id = "betterchunkloader", @@ -114,12 +115,14 @@ public void onServerAboutStart(GameAboutToStartServerEvent event) throws IOExcep @Listener public void onServerStart(GameStartedServerEvent event) { - int count = 0; - count = getChunkLoaderData().stream().filter((chunkLoader) -> (chunkLoader.isLoadable())).map((chunkLoader) -> { - getChunkManager().loadChunkLoader(chunkLoader); - return chunkLoader; - }).map((_item) -> 1).reduce(count, Integer::sum); - getLogger().info("Activated " + count + " chunk loaders."); + Sponge.getScheduler().createTaskBuilder().delay(config.getCore().chunkLoader.loadDelay, TimeUnit.SECONDS).execute(() -> { + int count = 0; + count = getChunkLoaderData().stream().filter((chunkLoader) -> (chunkLoader.isLoadable())).map((chunkLoader) -> { + getChunkManager().loadChunkLoader(chunkLoader); + return chunkLoader; + }).map((_item) -> 1).reduce(count, Integer::sum); + getLogger().info("Activated " + count + " chunk loaders."); + }).submit(this); } @Listener diff --git a/src/main/java/net/moddedminecraft/betterchunkloader/config/CoreConfig.java b/src/main/java/net/moddedminecraft/betterchunkloader/config/CoreConfig.java index e00e4f0..2d6c830 100644 --- a/src/main/java/net/moddedminecraft/betterchunkloader/config/CoreConfig.java +++ b/src/main/java/net/moddedminecraft/betterchunkloader/config/CoreConfig.java @@ -37,6 +37,9 @@ public static class Menu { @ConfigSerializable public static class ChunkLoader { + @Setting(value = "LoadDelay", comment = "Delay before loading chunkloaders during startup. (Seconds).") + public Integer loadDelay = 10; + @Setting("Online") public Online online = new Online();