World Copying

Discussion in 'Spigot Plugin Development' started by DotRar, May 20, 2015.

  1. So, I created these classes for my new minigame:
    But the thing is, it just generates a random minecraft world. Can anyone help?
  2. This doesn't give us any context at all. What are you trying to achieve, and what specifically is going wrong?
  3. I'm trying to copy a template world folder and then create a world from that, but a random minecraft world is generated.
    Your order of operations:
    - Plugin loads
    - Overwrite loaded world files
    - Disable autosave on a world that's already loaded
    - Create new world as the world is already loaded

    You don't seem to be unloading the world you're trying to replace.
    • Like Like x 1
  5. Is this better?

    Code (Text):
    private FileHandler() {}
        private static FileHandler instance = new FileHandler();
        public static FileHandler getInstance() {
            return instance;
        public void setAutoSave() {
        public void create() {
            WorldCreator wc = new WorldCreator("world");
        public void boot(Plugin p) {
            Bukkit.unloadWorld("world", false);
            File world = new File(Bukkit.getWorldContainer(), "world");
            try {
            } catch (IOException e) {
            File src = new File(Bukkit.getWorldContainer(), "backup");
            File dest = new File(Bukkit.getWorldContainer(), "world");
            try {
                FileUtils.copyDirectory(src, dest);
            } catch (IOException e) {
  6. Have you tested it? It looks like it could work.

    *could because I have no idea how Bukkit handles world loading, unloading, etc
    • Like Like x 1
  7. Yeah, I did, it works. Thanks!