BSkyBlock/src/main/java/world/bentobox/bskyblock/BSkyBlock.java

98 lines
3.4 KiB
Java
Raw Normal View History

package world.bentobox.bskyblock;
2018-07-30 01:57:42 +02:00
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.WorldType;
2018-07-30 01:57:42 +02:00
import world.bentobox.bentobox.api.addons.GameModeAddon;
2018-08-06 16:40:16 +02:00
import world.bentobox.bentobox.api.configuration.Config;
import world.bentobox.bentobox.api.configuration.WorldSettings;
import world.bentobox.bskyblock.commands.AdminCommand;
import world.bentobox.bskyblock.commands.IslandCommand;
import world.bentobox.bskyblock.generators.ChunkGeneratorWorld;
2018-07-30 01:57:42 +02:00
/**
* Main BSkyBlock class - provides an island minigame in the sky
* @author tastybento
* @author Poslovitch
*/
public class BSkyBlock extends GameModeAddon {
private static final String NETHER = "_nether";
private static final String THE_END = "_the_end";
2018-07-30 01:57:42 +02:00
// Settings
private Settings settings;
@Override
public void onLoad() {
// Save the default config from config.yml
saveDefaultConfig();
// Load settings from config.yml. This will check if there are any issues with it too.
2018-08-06 16:40:16 +02:00
settings = new Config<>(this, Settings.class).loadConfigObject();
2018-07-30 01:57:42 +02:00
}
@Override
public void onEnable(){
// Register commands
new IslandCommand(this);
new AdminCommand(this);
}
@Override
public void onDisable() {
// Save settings
if (settings != null) {
2018-08-06 16:40:16 +02:00
new Config<>(this, Settings.class).saveConfigObject(settings);
2018-07-30 01:57:42 +02:00
}
}
/**
* @return the settings
*/
public Settings getSettings() {
return settings;
}
@Override
public void createWorlds() {
String worldName = settings.getWorldName();
if (getServer().getWorld(worldName) == null) {
getLogger().info("Creating BSkyBlock world ...");
}
// Create the world if it does not exist
islandWorld = WorldCreator.name(worldName).type(WorldType.FLAT).environment(World.Environment.NORMAL).generator(new ChunkGeneratorWorld(this))
.createWorld();
// Make the nether if it does not exist
if (settings.isNetherGenerate()) {
if (getServer().getWorld(worldName + NETHER) == null) {
log("Creating BSkyBlock's Nether...");
}
if (!settings.isNetherIslands()) {
netherWorld = WorldCreator.name(worldName + NETHER).type(WorldType.NORMAL).environment(World.Environment.NETHER).createWorld();
} else {
netherWorld = WorldCreator.name(worldName + NETHER).type(WorldType.FLAT).generator(new ChunkGeneratorWorld(this))
.environment(World.Environment.NETHER).createWorld();
}
}
// Make the end if it does not exist
if (settings.isEndGenerate()) {
if (getServer().getWorld(worldName + THE_END) == null) {
log("Creating BSkyBlock's End World...");
}
if (!settings.isEndIslands()) {
endWorld = WorldCreator.name(worldName + THE_END).type(WorldType.NORMAL).environment(World.Environment.THE_END).createWorld();
} else {
endWorld = WorldCreator.name(worldName + THE_END).type(WorldType.FLAT).generator(new ChunkGeneratorWorld(this))
.environment(World.Environment.THE_END).createWorld();
}
}
}
@Override
public WorldSettings getWorldSettings() {
return settings;
}
2018-07-30 01:57:42 +02:00
}