Bugs on world regen:

Discussion in 'Spigot Plugin Development' started by ericevo, Sep 5, 2018.

  1. Hey there! Im having some issues whit the world-regen in my SkyWars plugin:
    [​IMG] [​IMG] [​IMG] [​IMG]

    Code to regen the map:
    https://hastebin.com/lolivojuda.php

    Btw, world regen is by copy - paste worlds.
     
  2. Bump...... Please help me
     
  3. I found the problem: you forgot to write the code.
    [​IMG]
     
    • Funny Funny x 2
    • Optimistic Optimistic x 1
  4. https://pastebin.com/UPwYUdVt

    (I think hastebin is down... lol)
     
  5. What is the body of this method:

    Utils.copyDirectory(file2, file);
     
  6. https://pastebin.com/znQrs7ej

    Btw, the server has been freezed, and throwed me this: https://pastebin.com/bjkGuXgp

    And, sometimes it gives me the error:
    [21:37:27] [Server thread/ERROR]: Couldn't save chunk; already in use by another instance of Minecraft?
    net.minecraft.server.v1_8_R3.ExceptionWorldConflict: The save for world located at ./Vidrios is being accessed from another location, aborting
     
  7. Bump again, lol
     
  8. What I would do is unload the world, wait a tick and then copy the directory. Doing things in the same tick with Bukkit can sometimes cause issues, though I'm not sure whether that is also the case here, it's worth a shot.

    You also silenced an exception in the copyFile method. Please print that one out to be sure there is no exception occuring there (e.g. not being able to write the file because it's still used by a process)
    catch (Exception ex) {}

    Before copying the directory (map) you should consider deleting/emptying the world directory first.
     
  9. Thanks, I'll try it :)
     

  10. Still not working, The method works but the chunks still bugged...

    Any another fix? Thanks ^-^
     
  11. Youhave to remove the directory before copy it

    Code (Text):

    public void regenMap() {
           Bukkit.unloadWorld(name, false);
     
           final File file = new File(name);
           final File file2 = new File("plugins/ComuWars/mapas/" + name);

       try {
                FileUtils.deleteDirectory(file);

                FileUtils.copyDirectory(file2, file);
            } catch (IOException e) {
                e.printStackTrace();
            }

               final WorldCreator worldCreator = new WorldCreator(name);
               worldCreator.generateStructures(false);
               final World world = worldCreator.createWorld();
               world.setAutoSave(false);
               world.setKeepSpawnInMemory(false);
               world.setAnimalSpawnLimit(0);
               world.setGameRuleValue("doMobSpawning", "false");
               world.setGameRuleValue("doDaylightCycle", "false");
               world.setGameRuleValue("mobGriefing", "false");
               world.setTime(0L);      
     
    It is also not necessary to create a file copy system, apache has a utility library for this org.apache.commons.io.FileUtils
     
    #11 ZNetwork, Sep 7, 2018
    Last edited: Sep 7, 2018
  12. RollBack: https://pastebin.com/1KGpa7Gw

    Utils: https://pastebin.com/zsm3Jsyk

    Still not working...