Example #1
0
 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;
 }
Example #2
0
 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;
 }
Example #3
0
 public static void setGenerator(String worldname, String name) {
   WorldConfig.get(worldname).chunkGeneratorName = name;
 }
Example #4
0
 public static String getGeneratorPlugin(String forWorld) {
   return WorldConfig.get(forWorld).chunkGeneratorName;
 }
Example #5
0
 public static Position getRespawn(String ofWorld) {
   return WorldConfig.get(ofWorld).spawnPoint;
 }
Example #6
0
 public static void setSpawn(String forWorld, Position destination) {
   WorldConfig.get(forWorld).spawnPoint = destination;
 }