From 86a660b53047603a9cb1879868a3f19e745c36c1 Mon Sep 17 00:00:00 2001 From: tastybento Date: Sat, 4 May 2019 10:12:48 -0700 Subject: [PATCH] Moves to onLoad to enable startup operation --- pom.xml | 2 +- .../world/bentobox/bskyblock/BSkyBlock.java | 23 +++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/pom.xml b/pom.xml index cfb6aee..971e451 100644 --- a/pom.xml +++ b/pom.xml @@ -91,7 +91,7 @@ world.bentobox bentobox - 1.4.0 + 1.5.0-SNAPSHOT provided diff --git a/src/main/java/world/bentobox/bskyblock/BSkyBlock.java b/src/main/java/world/bentobox/bskyblock/BSkyBlock.java index d28b428..745a32e 100644 --- a/src/main/java/world/bentobox/bskyblock/BSkyBlock.java +++ b/src/main/java/world/bentobox/bskyblock/BSkyBlock.java @@ -34,9 +34,15 @@ public class BSkyBlock extends GameModeAddon { saveDefaultConfig(); // Load settings from config.yml. This will check if there are any issues with it too. loadSettings(); + // Chunk generator + chunkGenerator = settings.isUseOwnGenerator() ? null : new ChunkGeneratorWorld(this); + // Register commands + playerCommand = new IslandCommand(this); + adminCommand = new AdminCommand(this); } private void loadSettings() { + // Load settings again to get worlds settings = new Config<>(this, Settings.class).loadConfigObject(); if (settings == null) { // Disable @@ -50,9 +56,7 @@ public class BSkyBlock extends GameModeAddon { @Override public void onEnable(){ - // Register commands - playerCommand = new IslandCommand(this); - adminCommand = new AdminCommand(this); + // Nothing to do here } @Override @@ -78,7 +82,7 @@ public class BSkyBlock extends GameModeAddon { if (getServer().getWorld(worldName) == null) { log("Creating BSkyBlock world ..."); } - chunkGenerator = settings.isUseOwnGenerator() ? null : new ChunkGeneratorWorld(this); + // Create the world if it does not exist islandWorld = getWorld(worldName, World.Environment.NORMAL, chunkGenerator); @@ -100,16 +104,16 @@ public class BSkyBlock extends GameModeAddon { /** * Gets a world or generates a new world if it does not exist - * @param worldName - the overworld name + * @param worldName2 - the overworld name * @param env - the environment * @param chunkGenerator2 - the chunk generator. If null then the generator will not be specified * @return world loaded or generated */ - private World getWorld(String worldName, Environment env, ChunkGeneratorWorld chunkGenerator2) { + private World getWorld(String worldName2, Environment env, ChunkGeneratorWorld chunkGenerator2) { // Set world name - worldName = env.equals(World.Environment.NETHER) ? worldName + NETHER : worldName; - worldName = env.equals(World.Environment.THE_END) ? worldName + THE_END : worldName; - WorldCreator wc = WorldCreator.name(worldName).type(WorldType.FLAT).environment(env); + worldName2 = env.equals(World.Environment.NETHER) ? worldName2 + NETHER : worldName2; + worldName2 = env.equals(World.Environment.THE_END) ? worldName2 + THE_END : worldName2; + WorldCreator wc = WorldCreator.name(worldName2).type(WorldType.FLAT).environment(env); return settings.isUseOwnGenerator() ? wc.createWorld() : wc.generator(chunkGenerator2).createWorld(); } @@ -128,6 +132,5 @@ public class BSkyBlock extends GameModeAddon { if (settings != null) { new Config<>(this, Settings.class).saveConfigObject(settings); } - } }