Added chunk generator method for GameModeAddon API

This commit is contained in:
tastybento 2019-01-26 15:42:47 -08:00
parent 55ed2640d1
commit c3a892c1b7
2 changed files with 13 additions and 4 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.1-SNAPSHOT</version> <version>1.1.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -3,6 +3,8 @@ package world.bentobox.bskyblock;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.WorldCreator; import org.bukkit.WorldCreator;
import org.bukkit.WorldType; import org.bukkit.WorldType;
import org.bukkit.generator.ChunkGenerator;
import org.eclipse.jdt.annotation.NonNull;
import world.bentobox.bentobox.api.addons.GameModeAddon; import world.bentobox.bentobox.api.addons.GameModeAddon;
import world.bentobox.bentobox.api.configuration.Config; import world.bentobox.bentobox.api.configuration.Config;
@ -23,6 +25,7 @@ public class BSkyBlock extends GameModeAddon {
// Settings // Settings
private Settings settings; private Settings settings;
private ChunkGeneratorWorld chunkGenerator;
@Override @Override
public void onLoad() { public void onLoad() {
@ -75,8 +78,9 @@ public class BSkyBlock extends GameModeAddon {
if (getServer().getWorld(worldName) == null) { if (getServer().getWorld(worldName) == null) {
getLogger().info("Creating BSkyBlock world ..."); getLogger().info("Creating BSkyBlock world ...");
} }
chunkGenerator = new ChunkGeneratorWorld(this);
// Create the world if it does not exist // Create the world if it does not exist
islandWorld = WorldCreator.name(worldName).type(WorldType.FLAT).environment(World.Environment.NORMAL).generator(new ChunkGeneratorWorld(this)) islandWorld = WorldCreator.name(worldName).type(WorldType.FLAT).environment(World.Environment.NORMAL).generator(chunkGenerator)
.createWorld(); .createWorld();
// Make the nether if it does not exist // Make the nether if it does not exist
@ -87,7 +91,7 @@ public class BSkyBlock extends GameModeAddon {
if (!settings.isNetherIslands()) { if (!settings.isNetherIslands()) {
netherWorld = WorldCreator.name(worldName + NETHER).type(WorldType.NORMAL).environment(World.Environment.NETHER).createWorld(); netherWorld = WorldCreator.name(worldName + NETHER).type(WorldType.NORMAL).environment(World.Environment.NETHER).createWorld();
} else { } else {
netherWorld = WorldCreator.name(worldName + NETHER).type(WorldType.FLAT).generator(new ChunkGeneratorWorld(this)) netherWorld = WorldCreator.name(worldName + NETHER).type(WorldType.FLAT).generator(chunkGenerator)
.environment(World.Environment.NETHER).createWorld(); .environment(World.Environment.NETHER).createWorld();
} }
} }
@ -99,7 +103,7 @@ public class BSkyBlock extends GameModeAddon {
if (!settings.isEndIslands()) { if (!settings.isEndIslands()) {
endWorld = WorldCreator.name(worldName + THE_END).type(WorldType.NORMAL).environment(World.Environment.THE_END).createWorld(); endWorld = WorldCreator.name(worldName + THE_END).type(WorldType.NORMAL).environment(World.Environment.THE_END).createWorld();
} else { } else {
endWorld = WorldCreator.name(worldName + THE_END).type(WorldType.FLAT).generator(new ChunkGeneratorWorld(this)) endWorld = WorldCreator.name(worldName + THE_END).type(WorldType.FLAT).generator(chunkGenerator)
.environment(World.Environment.THE_END).createWorld(); .environment(World.Environment.THE_END).createWorld();
} }
} }
@ -109,4 +113,9 @@ public class BSkyBlock extends GameModeAddon {
public WorldSettings getWorldSettings() { public WorldSettings getWorldSettings() {
return settings; return settings;
} }
@Override
public @NonNull ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
return chunkGenerator;
}
} }