public static Position[] getSpawnPoints() { Collection<WorldConfig> all = WorldConfig.all(); Position[] pos = new Position[all.size()]; int i = 0; for (WorldConfig wc : all) { pos[i] = wc.spawnPoint; i++; } return pos; }
public static World createWorld(String worldname, long seed) { String gen = getGeneratorPlugin(worldname); if (gen == null) { MyWorlds.log(Level.INFO, "Loading or creating world: '" + worldname + "' using seed " + seed); } else { MyWorlds.log( Level.INFO, "Loading or creating world: '" + worldname + "' using seed " + seed + " and chunk generator: '" + gen + "'"); } final int retrycount = 3; World w = null; int i = 0; ChunkGenerator cgen = null; try { if (gen != null) { cgen = getGenerator(worldname, gen); } } catch (Exception ex) { } if (gen != null && cgen == null) { MyWorlds.log( Level.SEVERE, "World '" + worldname + "' could not be loaded because the chunk generator '" + gen + "' was not found!"); return null; } WorldConfig wc = WorldConfig.get(worldname); wc.chunkGeneratorName = gen; for (i = 0; i < retrycount + 1; i++) { try { WorldCreator c = new WorldCreator(worldname); c.environment(wc.environment); c.seed(seed); c.generator(cgen); w = c.createWorld(); } catch (Exception ex) { MyWorlds.log(Level.WARNING, "World load issue: " + ex.getMessage()); } if (w != null) break; } if (w != null) { wc.updatePVP(w); // Data file is made? if (!worldExists(worldname)) { w.save(); } } if (w == null) { MyWorlds.log(Level.WARNING, "Operation failed after " + i + " retries!"); } else if (i == 1) { MyWorlds.log(Level.INFO, "Operation succeeded after 1 retry!"); } else if (i > 0) { MyWorlds.log(Level.INFO, "Operation succeeded after " + i + " retries!"); } return w; }
public static void setGenerator(String worldname, String name) { WorldConfig.get(worldname).chunkGeneratorName = name; }
public static String getGeneratorPlugin(String forWorld) { return WorldConfig.get(forWorld).chunkGeneratorName; }
public static Position getRespawn(String ofWorld) { return WorldConfig.get(ofWorld).spawnPoint; }
public static void setSpawn(String forWorld, Position destination) { WorldConfig.get(forWorld).spawnPoint = destination; }