Trying to delete then regenerate a world.

Discussion in 'Plugin Development' started by _8Bit, Jul 9, 2013.

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

    _8Bit

    Hey everyone, I have been stuck on this for hours. I am trying to delete a world, regenerate the world, then tp all players to that world, but whenever I regenerate the world after deleting, I get this:

    Code:
    Unloaded World
    21:20:34 [INFO] Deleting PvP World
    21:20:34 [INFO] Creating New World!
    21:20:34 [INFO] Preparing start region for level 3 (Seed: -5633050873844280746)
    21:20:34 [SEVERE] net.minecraft.server.v1_6_R2.ReportedException: Exception ticking world
    21:20:34 [SEVERE]    at net.minecraft.server.v1_6_R2.MinecraftServer.t(MinecraftServer.java:568)
    21:20:34 [SEVERE]    at net.minecraft.server.v1_6_R2.DedicatedServer.t(DedicatedServer.java:226)
    21:20:34 [SEVERE]    at net.minecraft.server.v1_6_R2.MinecraftServer.s(MinecraftServer.java:486)
    21:20:34 [SEVERE]    at net.minecraft.server.v1_6_R2.MinecraftServer.run(MinecraftServer.java:419)
    21:20:34 [SEVERE]    at net.minecraft.server.v1_6_R2.ThreadServerApplication.run(SourceFile:582)
    21:20:34 [SEVERE] Caused by: java.lang.IllegalStateException: TickNextTick list out of synch
    21:20:34 [SEVERE]    at net.minecraft.server.v1_6_R2.WorldServer.a(WorldServer.java:491)
    21:20:34 [SEVERE]    at net.minecraft.server.v1_6_R2.WorldServer.doTick(WorldServer.java:199)
    21:20:34 [SEVERE]    at net.minecraft.server.v1_6_R2.MinecraftServer.t(MinecraftServer.java:564)
    21:20:34 [SEVERE]    ... 4 more
    21:20:34 [SEVERE] Encountered an unexpected exception ReportedException
    net.minecraft.server.v1_6_R2.ReportedException: Exception ticking world
        at net.minecraft.server.v1_6_R2.MinecraftServer.t(MinecraftServer.java:568)
        at net.minecraft.server.v1_6_R2.DedicatedServer.t(DedicatedServer.java:226)
        at net.minecraft.server.v1_6_R2.MinecraftServer.s(MinecraftServer.java:486)
        at net.minecraft.server.v1_6_R2.MinecraftServer.run(MinecraftServer.java:419)
        at net.minecraft.server.v1_6_R2.ThreadServerApplication.run(SourceFile:582)
    Caused by: java.lang.IllegalStateException: TickNextTick list out of synch
        at net.minecraft.server.v1_6_R2.WorldServer.a(WorldServer.java:491)
        at net.minecraft.server.v1_6_R2.WorldServer.doTick(WorldServer.java:199)
        at net.minecraft.server.v1_6_R2.MinecraftServer.t(MinecraftServer.java:564)
        ... 4 more
    21:20:34 [SEVERE] This crash report has been saved to: /Users/fourbytes/Desktop/PluginTests/./crash-reports/crash-2013-07-09_21.20.34-server.txt
    21:20:35 [INFO] Preparing spawn area for pvpworld, 16%
    21:20:36 [INFO] Preparing spawn area for pvpworld, 36%
    21:20:37 [INFO] Preparing spawn area for pvpworld, 52%
    21:20:38 [INFO] Preparing spawn area for pvpworld, 81%
    21:20:39 [INFO] Preparing spawn area for pvpworld, 97%
    21:20:39 [INFO] World Created!
    
    Then when I teleport to that world, I just start falling and it's just blue sky.

    Here is my code:
    Code:java
    1.  
    2. public boolean deleteWorld(String file) {
    3. if(Bukkit.unloadWorld(file, false))
    4. System.out.println("Unloaded World");
    5.  
    6. System.out.println("Deleting PvP World");
    7.  
    8. try {
    9. FileUtils.deleteDirectory(new File(file + File.separator));
    10. } catch (IOException e) {
    11. e.printStackTrace();
    12. }
    13.  
    14. if(!new File(file + File.separator).exists()) {
    15. return true;
    16. } else
    17. return false;
    18. }
    19.  
    20. public static void createWorld(String world)
    21. {
    22. System.out.println("Creating New World!");
    23. Bukkit.createWorld(new WorldCreator(world).environment(Environment.NORMAL));
    24. System.out.println("World Created!");
    25. }
    26.  


    I call it like so:
    Code:java
    1.  
    2. deleteWorld("pvpworld")
    3. createWorld("pvpworld")
    4.  


    Can anyone find what I am doing wrong? :/

    Bump?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
  2. Offline

    _8Bit

    Bump again? I'm really stuck on this?
     
  3. Offline

    xTrollxDudex

    _8Bit
    Create world must be delayed because when you create the world the thread is still asleep...
     
  4. Offline

    _8Bit

    Can you give me an example of how I would do that xTrollxDudex ? Sorry I don't really know what you mean.
     
  5. You are causing the thread to sleep to long.
    Code:
     Thread.sleep(2000);
     
  6. Offline

    _8Bit

    Ah OK, thanks.

    Hm, removed that whole
    Code:java
    1.  
    2. try {
    3. Thread.sleep(2000);
    4. } catch (InterruptedException e) {
    5. e.printStackTrace();
    6. }
    7.  

    bit, but it still gives the same error, no change whatsoever...
    BorisTheTerrible xTrollxDudex

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
  7. Offline

    xTrollxDudex

    _8Bit
    Why does the thread need to be slept? Show us all the classes involving this.
    Anyway:
    Code:java
    1. <main class name> plugin;
    2. public <this class's name>(<main class name> plugin){
    3. this.plugin = plugin;
    4. }
    5. deleteWorld("pvpworld");
    6. Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
    7. @Override
    8. public void run(){
    9. createWorld("pvpworld");
    10. }
    11. }, 2001L)
     
  8. Offline

    _8Bit

    xTrollxDudex this is my current code, top function is where I call it from, and that is just called from another function which is just a timer, which is called from onenable
    Code:java
    1.  
    2.  
    3. public void startGame() {
    4. // Set max game length
    5. maxGameTime = getConfig().getInt("General.Game.MaxGameLength");
    6.  
    7. // Set current game length
    8. gameTime = 0;
    9.  
    10. for(Player p : Bukkit.getOnlinePlayers()) {
    11. p.getInventory().clear();
    12. p.getInventory().setHelmet(null);
    13. p.getInventory().setChestplate(null);
    14. p.getInventory().setLeggings(null);
    15. p.getInventory().setBoots(null);
    16. p.teleport(new Location(Bukkit.getWorld(pvpworld), Bukkit.getWorld(pvpworld).getSpawnLocation().getBlockX(), 128, Bukkit.getWorld(pvpworld).getSpawnLocation().getBlockZ()));
    17. ignoreFallDamage.add(p.getName());
    18. }
    19.  
    20. Timer fallTimer = new Timer();
    21. fallTimer.schedule(new TimerTask() {
    22. @Override
    23. public void run() {
    24. for(Player p : Bukkit.getOnlinePlayers()) {
    25. ignoreFallDamage.remove(p.getName());
    26. }
    27. }
    28. }, 6*1000);
    29.  
    30. // Start the game timer, this runs every 10 seconds.
    31. gameTimer = new Timer();
    32. gameTimer.schedule(new TimerTask() {
    33. @Override
    34. public void run() {
    35. if(gameTime <= maxGameTime)
    36. Bukkit.broadcastMessage(ChatColor.BLUE + "Time left: " + (maxGameTime-gameTime) + " seconds.");
    37. gameTime += 10;
    38. if(gameTime >= maxGameTime) {
    39. // Teleport everyone to lobby world and announce winner.
    40. for(Player p : Bukkit.getOnlinePlayers()) {
    41. p.getInventory().clear();
    42. p.getInventory().setHelmet(null);
    43. p.getInventory().setChestplate(null);
    44. p.getInventory().setLeggings(null);
    45. p.getInventory().setBoots(null);
    46. World world = Bukkit.getWorld(lobbyworld);
    47. p.teleport(world.getSpawnLocation());
    48. }
    49. gameTimer.cancel();
    50. inProgress = false;
    51. readyGame(cooldownOnStartup);
    52. deleteWorld(pvpworld);
    53. createWorld(pvpworld);
    54. }
    55.  
    56. }
    57. }, 0, 10*1000);
    58.  
    59. }
    60.  
    61. public boolean deleteWorld(String file) {
    62. if(Bukkit.unloadWorld(file, false))
    63. System.out.println("Unloaded World");
    64.  
    65. System.out.println("Deleting PvP World");
    66.  
    67. try {
    68. FileUtils.deleteDirectory(new File(file + File.separator));
    69. } catch (IOException e) {
    70. e.printStackTrace();
    71. }
    72.  
    73. if(!new File(file + File.separator).exists()) {
    74. return true;
    75. } else
    76. return false;
    77. }
    78.  
    79. public static void createWorld(String world)
    80. {
    81. System.out.println("Creating New World!");
    82. Bukkit.createWorld(new WorldCreator(world).environment(Environment.NORMAL));
    83. System.out.println("World Created!");
    84. }
    85.  
     
  9. _8Bit You need to check to make sure the world is deleted at line 53 like.
    Code:
    if (deleteWorld(pvpworld){
     
    createWorld(pvpworld)
     
    }
    Idk if that will fix your problem though.
     
  10. Offline

    Sessional

    _8Bit
    Chances are you need to tell bukkit to stop running updates on the world. Every time bukkit does an update it is called a 'tick', by 'ticking' a world you are just updating it. There is probably a way to unload a world from bukkit.

    Have you tried just using world.regenerateChunk(x, y) to regen it rather then deleting the whole world?

    http://jd.bukkit.org/rb/doxygen/dd/...1World.html#ac14ac2af857ee8ca21e5d318fd936017

    EDIT: Eh. Found unloading a world: http://jd.bukkit.org/rb/doxygen/d4/...Server.html#aa37af379fe2d4f8dc9052c556d2723aa
     
  11. Offline

    _8Bit

    I'll try world.regenerateChunk(), what would be the best way to loop through chunks in a 1000 block radius? Also, anyone know a way to change the seed?
     
  12. Offline

    foodyling

Thread Status:
Not open for further replies.

Share This Page