leftover chunks :/

Discussion in 'Plugin Development' started by lrdemolition, Aug 29, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    lrdemolition

    In my plugin I have to delete terrain that has already been used by players(at the end of each match).
    to do this i go through all the files in side the "getworld("arena").getFolder()" and delete them, and then i delete the world's whole folder. when i run the next game a new world is created, but all the chunks that were loaded in the previous world are still there. can someone explain to me how to get rid of previously loaded chunks and make sure the new world i create every time is in place of all chunks from te old one. thanks
     
  2. Offline

    Gamecube762

    Make sure that the whole world is unloaded before hand.
     
  3. Offline

    lrdemolition

    Gamecube762
    ill show you my code

    Code:
                   
                    /**for (Chunk c : Bukkit.getServer().getWorld("arena").getLoadedChunks()){
                        c.unload();
                    }
                    for (Chunk c : Bukkit.getServer().getWorld("arena_nether").getLoadedChunks()){
                        c.unload();
                    }
                    */
                    Bukkit.getServer().unloadWorld("arena", false);
                    Bukkit.getServer().unloadWorld("arena_nether", false);
                    File f = (File) Bukkit.getWorld("arena").getWorldFolder();
                    File fn = (File) Bukkit.getWorld("arena_nether").getWorldFolder();
                    if (Bukkit.getWorld("arena").getWorldFolder().isDirectory()) {
                            for (File c : f.listFiles())
                              c.delete();
                            f.delete();
                    }
                    if (Bukkit.getWorld("arena_nether").getWorldFolder().isDirectory()) {
                        for (File c : fn.listFiles())
                          c.delete();
                        fn.delete();
                  }
    Gamecube762

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 10, 2016
  4. @lrdemolition
    Did you check whether the folder is deleted with file manager?
     
Thread Status:
Not open for further replies.

Share This Page