public World create(org.bukkit.WorldType type) { if (type == null) { type = org.bukkit.WorldType.NORMAL; } try { if (WorldUtil.isLoaded(this.worldName) != null || WorldUtil.exists(this.worldName) != null) { throw new IllegalStateException("World already exists"); } } catch (final IOException e) { return null; } final WorldCreator creator = new WorldCreator(this.worldName); creator.seed(this.getSeed()); creator.type(type); switch (this.type) { case ADDITIONAL: case STOCK: creator.environment(World.Environment.NORMAL); break; case ADDITIONAL_SUB_NETHER: case STOCK_NETHER: creator.environment(World.Environment.NETHER); break; case ADDITIONAL_SUB_END: case STOCK_END: creator.environment(World.Environment.THE_END); break; default: throw new IllegalStateException("Incorrect world type: " + this.type); } final World result = creator.createWorld(); this.setSpawnLocation(result.getSpawnLocation()); return result; }
public boolean exists() { try { return WorldUtil.exists(this.worldName) != null; } catch (final IOException e) { e.printStackTrace(); return false; } }
public World load() { try { if (this.isLoaded()) { throw new IllegalStateException("World already loaded"); } else if (WorldUtil.exists(this.worldName) == null) { throw new IllegalStateException("World does not exists"); } } catch (final IOException e) { return null; } final WorldCreator creator = new WorldCreator(this.worldName); final World result = creator.createWorld(); if (this.spawnLocation == null) { this.setSpawnLocation(result.getSpawnLocation()); } this.setEnabled(true); return result; }
public boolean isLoaded() { return WorldUtil.isLoaded(this.worldName) != null; }