Moves to onLoad to enable startup operation

This commit is contained in:
tastybento 2019-05-04 10:12:48 -07:00
parent fe719121f4
commit 2566cac99d
2 changed files with 14 additions and 11 deletions

View File

@ -91,7 +91,7 @@
<dependency> <dependency>
<groupId>world.bentobox</groupId> <groupId>world.bentobox</groupId>
<artifactId>bentobox</artifactId> <artifactId>bentobox</artifactId>
<version>1.4.0</version> <version>1.5.0-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -34,9 +34,15 @@ public class BSkyBlock extends GameModeAddon {
saveDefaultConfig(); saveDefaultConfig();
// Load settings from config.yml. This will check if there are any issues with it too. // Load settings from config.yml. This will check if there are any issues with it too.
loadSettings(); loadSettings();
// Chunk generator
chunkGenerator = settings.isUseOwnGenerator() ? null : new ChunkGeneratorWorld(this);
// Register commands
playerCommand = new IslandCommand(this);
adminCommand = new AdminCommand(this);
} }
private void loadSettings() { private void loadSettings() {
// Load settings again to get worlds
settings = new Config<>(this, Settings.class).loadConfigObject(); settings = new Config<>(this, Settings.class).loadConfigObject();
if (settings == null) { if (settings == null) {
// Disable // Disable
@ -50,9 +56,7 @@ public class BSkyBlock extends GameModeAddon {
@Override @Override
public void onEnable(){ public void onEnable(){
// Register commands // Nothing to do here
playerCommand = new IslandCommand(this);
adminCommand = new AdminCommand(this);
} }
@Override @Override
@ -78,7 +82,7 @@ public class BSkyBlock extends GameModeAddon {
if (getServer().getWorld(worldName) == null) { if (getServer().getWorld(worldName) == null) {
log("Creating BSkyBlock world ..."); log("Creating BSkyBlock world ...");
} }
chunkGenerator = settings.isUseOwnGenerator() ? null : new ChunkGeneratorWorld(this);
// Create the world if it does not exist // Create the world if it does not exist
islandWorld = getWorld(worldName, World.Environment.NORMAL, chunkGenerator); 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 * 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 env - the environment
* @param chunkGenerator2 - the chunk generator. If <tt>null</tt> then the generator will not be specified * @param chunkGenerator2 - the chunk generator. If <tt>null</tt> then the generator will not be specified
* @return world loaded or generated * @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 // Set world name
worldName = env.equals(World.Environment.NETHER) ? worldName + NETHER : worldName; worldName2 = env.equals(World.Environment.NETHER) ? worldName2 + NETHER : worldName2;
worldName = env.equals(World.Environment.THE_END) ? worldName + THE_END : worldName; worldName2 = env.equals(World.Environment.THE_END) ? worldName2 + THE_END : worldName2;
WorldCreator wc = WorldCreator.name(worldName).type(WorldType.FLAT).environment(env); WorldCreator wc = WorldCreator.name(worldName2).type(WorldType.FLAT).environment(env);
return settings.isUseOwnGenerator() ? wc.createWorld() : wc.generator(chunkGenerator2).createWorld(); return settings.isUseOwnGenerator() ? wc.createWorld() : wc.generator(chunkGenerator2).createWorld();
} }
@ -128,6 +132,5 @@ public class BSkyBlock extends GameModeAddon {
if (settings != null) { if (settings != null) {
new Config<>(this, Settings.class).saveConfigObject(settings); new Config<>(this, Settings.class).saveConfigObject(settings);
} }
} }
} }