Hey there! Im having some issues whit the world-regen in my SkyWars plugin: Code to regen the map: https://hastebin.com/lolivojuda.php Btw, world regen is by copy - paste worlds.
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: Spoiler: 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
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.
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