Skip to content

Commit

Permalink
Add configurable delay timer for loading chunk loaders at startup
Browse files Browse the repository at this point in the history
  • Loading branch information
leelawd committed Mar 31, 2018
1 parent ed8104c commit 063dd72
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.io.IOException;
import java.nio.file.Path;
import java.util.*;
import java.util.concurrent.TimeUnit;

@Plugin(
id = "betterchunkloader",
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 063dd72

Please sign in to comment.