Need Help with World Creating and Copying

Discussion in 'Spigot Plugin Development' started by MrGamingLion66, May 2, 2017.

  1. Hey everyone, to make arenas for my servers sky wars plugin I create a new world temporarily copied from a default version of that world. However, the copying and the world generation are not working. Any help would be appreciated.

    World creating code:
    Code (Text):
    World world = Bukkit.getServer().createWorld(new WorldCreator("SkyWars" + i)); //i is the number of arenas existing
    World copying code:
    Code (Text):
    public void copyWorld(File source, File target){

            try {

                ArrayList<String> ignore = new ArrayList<String>(Arrays.asList("uid.dat", "session.dat"));

                if(!ignore.contains(source.getName())) {

                    if(source.isDirectory()) {



                        String files[] = source.list();

                        for (String file : files) {

                            File srcFile = new File(source, file);

                            File destFile = new File(target, file);

                            copyWorld(srcFile, destFile);


                    } else {

                        InputStream in = new FileInputStream(source);

                        OutputStream out = new FileOutputStream(target);

                        byte[] buffer = new byte[1024];

                        int length;

                        while ((length = > 0)

                            out.write(buffer, 0, length);





            } catch (IOException e) {


  2. Are you unloading the world then copying it and loading it back up?

    Sent from my iPhone using Tapatalk
  3. Since I'm away from my computer I can't be to sure but I think there is a thing for copying worlds.

    EDIT: Nope isn't a method
    #3 xPlumpOrange, May 2, 2017
    Last edited: May 2, 2017
  4. not a method provided.
    • Like Like x 2
  5. @ChefJava @xPlumpOrange @dNiym
    Okay I found this error in the console:
    Couldn't save chunk; already in use by another instance of Minecraft?
    net.minecraft.server.v1_10_R1.ExceptionWorldConflict: The save for world located at .\SkyWars1 is being accessed from another location, aborting
    at net.minecraft.server.v1_10_R1.WorldNBTStorage.checkSession( ~[spigot-1.10.2.jar:git-Spigot-de459a2-51263e9]
    at net.minecraft.server.v1_10_R1.World.checkSession( ~[spigot-1.10.2.jar:git-Spigot-de459a2-51263e9]
    at net.minecraft.server.v1_10_R1.ChunkRegionLoader.a( ~[spigot-1.10.2.jar:git-Spigot-de459a2-51263e9]
    at net.minecraft.server.v1_10_R1.ChunkProviderServer.saveChunk( [spigot-1.10.2.jar:git-Spigot-de459a2-51263e9]
    at net.minecraft.server.v1_10_R1.ChunkProviderServer.unloadChunk( [spigot-1.10.2.jar:git-Spigot-de459a2-51263e9]
    at net.minecraft.server.v1_10_R1.ChunkProviderServer.unloadChunks( [spigot-1.10.2.jar:git-Spigot-de459a2-51263e9]
    at net.minecraft.server.v1_10_R1.WorldServer.doTick( [spigot-1.10.2.jar:git-Spigot-de459a2-51263e9]
    at net.minecraft.server.v1_10_R1.MinecraftServer.D( [spigot-1.10.2.jar:git-Spigot-de459a2-51263e9]
    at net.minecraft.server.v1_10_R1.DedicatedServer.D( [spigot-1.10.2.jar:git-Spigot-de459a2-51263e9]
    at net.minecraft.server.v1_10_R1.MinecraftServer.C( [spigot-1.10.2.jar:git-Spigot-de459a2-51263e9]
    at [spigot-1.10.2.jar:git-Spigot-de459a2-51263e9]
    at Source) [?:1.8.0_111]
  6. This

    Sent from my iPhone using Tapatalk
  7. Exactly^ unload it first. I was getting this issue too when trying to copy world folders using that same code :p, World#unload first before you copy

    Sent from my iPhone using Tapatalk
  8. Code (Java):

    public static boolean copyDir(Path dir, Path dest)
         catch(IOException e)
           return false;
         File d = dir.toFile();
           return false;
           File[] fs = d.listFiles();
           if(fs != null)
             for(File f : fs)
                 return false;

         return true;