mirror of
https://github.com/BentoBoxWorld/BSkyBlock.git
synced 2024-06-23 09:54:48 +02:00
Version up. Uses new GameModeAddon API.
This commit is contained in:
parent
d321d1f53a
commit
f8986f340a
4
pom.xml
4
pom.xml
|
@ -6,7 +6,7 @@
|
|||
|
||||
<groupId>world.bentobox</groupId>
|
||||
<artifactId>BSkyBlock</artifactId>
|
||||
<version>0.5.0-SNAPSHOT</version>
|
||||
<version>0.6.0-SNAPSHOT</version>
|
||||
|
||||
<name>BSkyBlock</name>
|
||||
<description>BSkyBlock is an add-on for BentoBox, an expandable Minecraft Bukkit plugin for island-type games like ASkyBlock or AcidIsland.</description>
|
||||
|
@ -91,7 +91,7 @@
|
|||
<dependency>
|
||||
<groupId>world.bentobox</groupId>
|
||||
<artifactId>bentobox</artifactId>
|
||||
<version>0.12.0-SNAPSHOT</version>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
@ -1,24 +1,30 @@
|
|||
package world.bentobox.bskyblock;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.WorldType;
|
||||
|
||||
import world.bentobox.bentobox.api.addons.Addon;
|
||||
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
||||
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.BSkyBlockWorld;
|
||||
import world.bentobox.bentobox.api.addons.Addon;
|
||||
import world.bentobox.bentobox.api.configuration.Config;
|
||||
import world.bentobox.bskyblock.generators.ChunkGeneratorWorld;
|
||||
|
||||
/**
|
||||
* Main BSkyBlock class - provides an island minigame in the sky
|
||||
* @author tastybento
|
||||
* @author Poslovitch
|
||||
*/
|
||||
public class BSkyBlock extends Addon {
|
||||
public class BSkyBlock extends GameModeAddon {
|
||||
|
||||
private static Addon addon;
|
||||
private static final String NETHER = "_nether";
|
||||
private static final String THE_END = "_the_end";
|
||||
|
||||
private static BSkyBlock addon;
|
||||
// Settings
|
||||
private Settings settings;
|
||||
private BSkyBlockWorld bsbWorlds;
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
|
@ -27,8 +33,6 @@ public class BSkyBlock extends Addon {
|
|||
saveDefaultConfig();
|
||||
// Load settings from config.yml. This will check if there are any issues with it too.
|
||||
settings = new Config<>(this, Settings.class).loadConfigObject();
|
||||
// Load or create worlds
|
||||
bsbWorlds = new BSkyBlockWorld(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -53,15 +57,48 @@ public class BSkyBlock extends Addon {
|
|||
return settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the BSkyBlock world
|
||||
*/
|
||||
public World getIslandWorld() {
|
||||
return bsbWorlds.getOverWorld();
|
||||
}
|
||||
|
||||
public static Addon getInstance() {
|
||||
return addon;
|
||||
}
|
||||
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ public class AdminCommand extends CompositeCommand {
|
|||
setOnlyPlayer(false);
|
||||
setParametersHelp("commands.admin.help.parameters");
|
||||
setDescription("commands.admin.help.description");
|
||||
setWorld(((BSkyBlock)getAddon()).getIslandWorld());
|
||||
new AdminVersionCommand(this);
|
||||
new AdminTeleportCommand(this, "tp");
|
||||
new AdminTeleportCommand(this, "tpnether");
|
||||
|
|
|
@ -35,7 +35,6 @@ public class IslandCommand extends CompositeCommand {
|
|||
setOnlyPlayer(true);
|
||||
// Permission
|
||||
setPermission("island");
|
||||
setWorld(((BSkyBlock)getAddon()).getIslandWorld());
|
||||
// Set up subcommands
|
||||
new IslandAboutCommand(this);
|
||||
new IslandCreateCommand(this);
|
||||
|
|
|
@ -1,90 +0,0 @@
|
|||
package world.bentobox.bskyblock.generators;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.WorldType;
|
||||
|
||||
import world.bentobox.bskyblock.BSkyBlock;
|
||||
import world.bentobox.bentobox.util.Util;
|
||||
|
||||
/**
|
||||
* Creates the worlds and registers them with BentoBox
|
||||
* @author tastybento
|
||||
*
|
||||
*/
|
||||
public class BSkyBlockWorld {
|
||||
|
||||
private static final String NETHER = "_nether";
|
||||
private static final String THE_END = "_the_end";
|
||||
private World islandWorld;
|
||||
private World netherWorld;
|
||||
private World endWorld;
|
||||
|
||||
/**
|
||||
* Create and register worlds with BentoBox
|
||||
* @param addon - addon
|
||||
*/
|
||||
public BSkyBlockWorld(BSkyBlock addon) {
|
||||
String worldName = addon.getSettings().getWorldName();
|
||||
if (addon.getServer().getWorld(worldName) == null) {
|
||||
addon.getLogger().info("Creating BSkyBlock worlds...");
|
||||
}
|
||||
// Create the world if it does not exist
|
||||
islandWorld = WorldCreator.name(worldName).type(WorldType.FLAT).environment(World.Environment.NORMAL).generator(new ChunkGeneratorWorld(addon))
|
||||
.createWorld();
|
||||
addon.getPlugin().registerWorld(islandWorld, addon.getSettings());
|
||||
|
||||
// Make the nether if it does not exist
|
||||
if (addon.getSettings().isNetherGenerate()) {
|
||||
if (addon.getServer().getWorld(worldName + NETHER) == null) {
|
||||
addon.log("Creating BSkyBlock's Nether...");
|
||||
}
|
||||
if (!addon.getSettings().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(addon))
|
||||
.environment(World.Environment.NETHER).createWorld();
|
||||
}
|
||||
}
|
||||
// Make the end if it does not exist
|
||||
if (addon.getSettings().isEndGenerate()) {
|
||||
if (addon.getServer().getWorld(worldName + THE_END) == null) {
|
||||
addon.log("Creating BSkyBlock's End World...");
|
||||
}
|
||||
if (!addon.getSettings().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(addon))
|
||||
.environment(World.Environment.THE_END).createWorld();
|
||||
}
|
||||
}
|
||||
|
||||
// Load schematics
|
||||
addon.getPlugin().getSchemsManager().loadIslands(islandWorld);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if a player is in any of the island worlds
|
||||
* @param loc - player to check
|
||||
* @return true if in a world or false if not
|
||||
*/
|
||||
public boolean inWorld(Location loc) {
|
||||
return Util.sameWorld(loc.getWorld(), islandWorld);
|
||||
}
|
||||
|
||||
public World getOverWorld() {
|
||||
return islandWorld;
|
||||
}
|
||||
|
||||
public World getNetherWorld() {
|
||||
return netherWorld;
|
||||
}
|
||||
|
||||
public World getEndWorld() {
|
||||
return endWorld;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user