The World is Being Accessed From Another Location

Discussion in 'Spigot Plugin Development' started by mrkirby153, May 29, 2015.

  1. I was working on creating virtual "servers" for my minigame so each game instance is in its own "server" (different world), but I'm having trouble cloning it from the template world. The world copies fine, but when minecraft does its world saving,

    Code (Text):
    [17:31:59] [Server thread/WARN]: net.minecraft.server.v1_8_R2.ExceptionWorldConflict: The save for world located at .\world-20 is being accessed from another location, aborting
    [17:31:59] [Server thread/WARN]:     at net.minecraft.server.v1_8_R2.WorldNBTStorage.checkSession(WorldNBTStorage.java:72)
    [17:31:59] [Server thread/WARN]:     at net.minecraft.server.v1_8_R2.World.checkSession(World.java:2831)
    [17:31:59] [Server thread/WARN]:     at net.minecraft.server.v1_8_R2.WorldServer.a(WorldServer.java:954)
    [17:31:59] [Server thread/WARN]:     at net.minecraft.server.v1_8_R2.WorldServer.save(WorldServer.java:926)
    [17:31:59] [Server thread/WARN]:     at org.bukkit.craftbukkit.v1_8_R2.CraftWorld.save(CraftWorld.java:755)
    [17:31:59] [Server thread/WARN]:     at net.minecraft.server.v1_8_R2.MinecraftServer.z(MinecraftServer.java:676)
    [17:31:59] [Server thread/WARN]:     at net.minecraft.server.v1_8_R2.MinecraftServer.run(MinecraftServer.java:554)
    is displayed in the console.

    I'm copying it like this:
    Code (Text):
        public static void copyTemplateWorld(String worldName, String serverName) {
            File baseWorld = new File(Bukkit.getWorldContainer(), worldName);
            File newWorld = new File(Bukkit.getWorldContainer(), serverName);

            try {
                FileUtils.copyDirectory(baseWorld, newWorld);
            } catch (IOException e) {
                e.printStackTrace();
                // TODO: better error handling
            }
            File uidFile = new File(newWorld, "uid.dat");
            uidFile.delete();
        }
    called like this:
    Code (Text):
    String type = rs.getString("type");
                    Core.plugin().getLogger().info("Loading server type " + type + "!");
                    int maxPlayers = rs.getInt("maxPlayers");
                    QuarxelLoc spawnLocation = new QuarxelLoc(rs.getString("spawnLocation"));
                    Location deserializedLoc = spawnLocation.deserialize();
                    int quantity = rs.getInt("quantity");
                    String templateWorld = rs.getString("templateWorldName");
                    // Begin loading the world(s)
                    Bukkit.unloadWorld(templateWorld, true);
                    for (int i = 1; i <= quantity; i++) {
                        copyTemplateWorld(templateWorld, templateWorld + "-" + i);
                        Bukkit.getServer().createWorld(new WorldCreator(templateWorld + "-" + i));
                        World w = Bukkit.getWorld(templateWorld + "-" + i);
                        deserializedLoc.setWorld(w);
                        // Dynamically load the VirtualServer
                        try {
                            VirtualServer server = (VirtualServer) Class.forName(type).getConstructor(String.class, Location.class).newInstance(w.getName(), deserializedLoc);
                            server.bindWorld(w);
                            registerServer(server);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                    Bukkit.getWorld(templateWorld);
    Why is it doing this?
     
  2. In case the world you copy is loaded as well, there is a session lock in the world folder. You might want to delete that as well :p.
     
  3. I tried deleting that and then I got a failed to check session.lock. Is there a way to update it to the current timestamp or something?
     
  4. I think the safest way to do this is to make sure the world is not loaded when you copy the files. Unfortunately I'm not too familiar with the way MC saves it's worlds so I'm not sure on how to properly remove the session lock.
     
  5. I've been having a similar problem as well, anyone know a solution? I didn't want to make a new thread for this.