World not resetting

Discussion in 'Plugin Development' started by Forseth11, May 27, 2014.

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

    Forseth11

    I am using this code to reset worlds:
    Code:java
    1. private static void unloadMap(String mapname){
    2. log("unloading map!", mapname);
    3. while((!Bukkit.getServer().unloadWorld(Bukkit.getServer().getWorld(mapname), false)) || (Bukkit.getServer().getWorld(mapname) != null)){
    4. World w = Bukkit.getServer().getWorld(mapname);
    5. if(w != null){
    6. if(w.getPlayers() != null){
    7. if(w.getPlayers().size() > 0){
    8. for(Player p : w.getPlayers()){
    9. p.kickPlayer("Teleport has failed to remove you from the game world so to prevent the map from not resetting we are kicking you to be assured that you do not cause it not to reset.");
    10. }
    11. }
    12. }
    13. if(w.getEntities() != null){
    14. w.getEntities().removeAll(w.getEntities());
    15. }
    16. }
    17. skyWarsMain.plugin.getLogger().severe("COULD NOT UNLOAD " + mapname);
    18. skyWarsMain.plugin.getLogger().severe("==========================================================================================================" +
    19. "========================================================================" +
    20. "=====================================================================" +
    21. "====================================================================" +
    22. "==============================================================" +
    23. "UNLOADERROR===============================================================" +
    24. "===========================================");
    25. skyWarsMain.plugin.getLogger().severe("SKYWARS ERROR: COULD NOT UNLOAD " + mapname);
    26. }
    27. }


    It works about 90% of the time, and when it does not work it does not post the long error message in the console. Why would it not reset? I have world auto saving off.
     
Thread Status:
Not open for further replies.

Share This Page