Problem with copying map

Discussion in 'Spigot Plugin Development' started by jusjus112, Jul 6, 2016.

  1. Hello guys,

    I have a big problem with copying my map. What i wanne do, is really simpel.
    I have world 1, and world 2. World 1 is the original map. And world 2 is the game_world (Where players can break)

    So, on a startup im copying world1 to a renamed world called world 2. So, the server is using world2 to play on.
    But, when i try to get my code working, it dont gives any errors. And it dont work. So, im confues, or what is wrong with my code?

    Here i currently copying the map:
    (He is generating 2 maps, but it dont copy)

    Code (Text):
        public void copyWorld() throws IOException {
            File data = new File(Core.getInstance().getDataFolder().getPath());
            String strData = data.toString();
            String[] split = strData.toString().split(File.pathSeparator);
            String rootFolder = split[split.length - 1];
            File root = new File(rootFolder);
            File bakupFolder = new File(root+"/"+"backup");
            if (!bakupFolder.exists()) {
                System.out.print("Backup folder bestaat niet");
                return;
            }
            File destDir = new File("/"+"world");
            System.out.print(destDir);
            FileUtil.copy(bakupFolder, destDir);
            Bukkit.getServer().createWorld(new WorldCreator("world"));
        }
       
        public void deleteWorld()throws IOException {
            Bukkit.getServer().unloadWorld("world", true);
            File dir = new File(Bukkit.getServer().getWorld("world").getWorldFolder().getPath());
            System.out.print(dir);
            dir.delete();
        }
    Hope you guys can help me out ;)
     
  2. Please guys ;(

    Is it that hard?
     
  3. Please don't bump within 24 hours, be patient.

    To get back ontopic, why not use a schematic and paste that?
     
  4. If you want to do this you have to say in the Plugin.yml to load the Plugin on startup of the server before the world's are loaded. If you have code that needs to be run after the world is loaded you can put them in a synchronised task.