Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2012
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.47 KB | None | 0 0
  1. HashMap regionfiles;
  2.         Field rafField;
  3.         boolean f = true;
  4.         killAllMobs();
  5.         World hg = Bukkit.getServer().getWorld("hg");
  6.         if(hg != null) {
  7.             for(Chunk c : hg.getLoadedChunks()) {
  8.                 hg.unloadChunk(c);
  9.             }
  10.             hg.setKeepSpawnInMemory(false);
  11.         }
  12.         log.info("World Unloading: " + Bukkit.getServer().unloadWorld(Bukkit.getServer().getWorld("hg"), false));      
  13.         try {
  14.             Field a = net.minecraft.server.RegionFileCache.class.getDeclaredField("a");
  15.             a.setAccessible(true);
  16.             regionfiles = (HashMap) a.get(null);
  17.             rafField = net.minecraft.server.RegionFile.class.getDeclaredField("c");
  18.             rafField.setAccessible(true);
  19.         } catch (Throwable t) {
  20.             log.severe("Couldn't release regionfiles");
  21.             t.printStackTrace();
  22.             return;
  23.         }
  24.         File WorldDir = new File(plugin.getDataFolder().getAbsoluteFile().getParentFile().getParentFile() + File.separator + "hg");
  25.         log.info("Deleting " + WorldDir.toString());
  26.         Functions.deleteFolder(WorldDir);
  27.         try {
  28.             Runtime.getRuntime().exec("rm -rf /srv/minecraft/test/hg");
  29.         } catch (IOException e) {
  30.             e.printStackTrace();
  31.             plugin.getServer().shutdown();
  32.         }
  33.         World newWorld = null;
  34.         WorldCreator wc = new WorldCreator("hg");
  35.         wc.generator();
  36.         wc.seed(Functions.getRandomSeed());
  37.         try {
  38.             newWorld = wc.createWorld();
  39.         } catch (Exception ex) {
  40.             log.severe("Unable to create new world.");
  41.         }
  42.         if(newWorld != null) {
  43.             log.info("Generated new world.");
  44.         }
  45.         regionfiles = null;
  46.         rafField = null;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement