Beispiel #1
0
 public static WorldInfo getInfo(String worldname) {
   WorldInfo info = null;
   try {
     Tag t = getData(worldname);
     if (t != null) {
       info = new WorldInfo();
       info.name = t.findTagByName("LevelName").getValue().toString();
       info.seed = (Long) t.findTagByName("RandomSeed").getValue();
       info.size = (Long) t.findTagByName("SizeOnDisk").getValue();
       info.time = (Long) t.findTagByName("Time").getValue();
       info.raining = ((Byte) t.findTagByName("raining").getValue()) != 0;
       info.thundering = ((Byte) t.findTagByName("thundering").getValue()) != 0;
       if (info.size == 0) info.size = getWorldSize(worldname);
     }
   } catch (Exception ex) {
   }
   World w = getWorld(worldname);
   if (w != null) {
     if (info == null) {
       info = new WorldInfo();
       info.size = getWorldSize(worldname);
     }
     info.name = w.getName();
     info.seed = w.getSeed();
     info.time = w.getFullTime();
     info.raining = w.hasStorm();
     info.thundering = w.isThundering();
   }
   return info;
 }
Beispiel #2
0
 private static boolean renameWorld(String worldname, String newname) {
   if (isLoaded(worldname)) return false;
   Tag t = getData(worldname);
   if (t == null) return false;
   t = t.findTagByName("Data");
   if (t == null || t.getType() != Type.TAG_Compound) return false;
   int i = 0;
   for (Tag tt : (Tag[]) t.getValue()) {
     if (tt.getName().equals("LevelName")) {
       t.removeTag(i);
       t.insertTag(new Tag(Type.TAG_String, "LevelName", newname), i);
       break;
     }
     i++;
   }
   return setData(worldname, t);
 }