Solved World Error

Discussion in 'Plugin Help/Development/Requests' started by MCMatters, Mar 21, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    MCMatters

    So my plugin calls this method and an error happened
    Code:
        public void end(){
            start = false;
            World world = Bukkit.getWorld("TNTGame");
            String s = "";
            if(red.isEmpty()){
                s = ChatColor.DARK_RED + "Red";
            }else{
                s = ChatColor.DARK_BLUE + "Blue";
            }
            for(Player p : Bukkit.getOnlinePlayers()){
                p.getInventory().clear();
                p.teleport(new Location(Bukkit.getWorld("TNTSpawn"), -10, 5, 11));
                if(red.contains(p.getName())) red.remove(p.getName());
                if(blue.contains(p.getName())) blue.remove(p.getName());
                rms(p);
            }
            Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', "&4TNTWars &7>> &aGame ended, " + s + " wins&6!"));
            unloadWorld(world);
            deleteWorld(new File("TNTGame"));
            if(Bukkit.getOnlinePlayers().size() >= 2){
                if(!cdown || !start){
                    Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', "&4TNTWars &7>> &aCountdown has started&6!"));
                    countdown(60);
                    cdown = true;
                }
            }
        }
       
        public void unloadWorld(World world) {
                Bukkit.getServer().unloadWorld(world, false);
        }
       
        public boolean deleteWorld(File path) {
              if(path.exists()) {
                  File files[] = path.listFiles();
                  for(int i=0; i<files.length; i++) {
                      if(files[i].isDirectory()) {
                          deleteWorld(files[i]);
                      } else {
                          files[i].delete();
                      }
                  }
              }
              return(path.delete());
        }
    Code:
    [22:31:59] [Server thread/WARN]: net.minecraft.server.v1_8_R1.ExceptionWorldConflict: Failed to check session lock for world located at ./TNTGame, aborting. Stop the server and delete the session.lock in this world to prevent further issues.
    [22:31:59] [Server thread/WARN]:     at net.minecraft.server.v1_8_R1.WorldNBTStorage.checkSession(WorldNBTStorage.java:79)
    [22:31:59] [Server thread/WARN]:     at net.minecraft.server.v1_8_R1.World.checkSession(World.java:2772)
    [22:31:59] [Server thread/WARN]:     at net.minecraft.server.v1_8_R1.WorldServer.a(WorldServer.java:934)
    [22:31:59] [Server thread/WARN]:     at net.minecraft.server.v1_8_R1.WorldServer.save(WorldServer.java:906)
    [22:31:59] [Server thread/WARN]:     at org.bukkit.craftbukkit.v1_8_R1.CraftWorld.save(CraftWorld.java:731)
    [22:31:59] [Server thread/WARN]:     at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:648)
    [22:31:59] [Server thread/WARN]:     at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:526)
    [22:31:59] [Server thread/WARN]:     at java.lang.Thread.run(Thread.java:745)
     
  2. Offline

    pie_flavor

    @MCMatters The error literally tells you exactly what to do.
     
  3. Offline

    MCMatters

    @pie_flavor
    How can i delete files that don't exist? If you would read and stop being smart, you would see that the method unloads and deletes the world. The reason I'm doing this is to make a playable map that regenerates. I copy TNTWars to TNTGame and load TNTGame and then TP all players. Then they play and at the end of the game i make it unload and delete. The problem is not in my code, It is probably that it doesn't unload properly. If I can't get a solution ill just make it that the server restarts at the end of the game
     
  4. Offline

    nverdier

    @MCMatters He's not "being smart". He's telling you that the stack trace tells you in text what to do, which it does.
     
  5. Offline

    MCMatters

    @nverdier I came to an conclusion that the unloading isn't working. That unloadWorld method won't work. Help?
    So in my plugin it should restart the server?
     
  6. Offline

    pie_flavor

    @MCMatters Try copying the files, and loading the new one. Or, maybe look into a Multiverse hook.
     
  7. Offline

    MCMatters

Thread Status:
Not open for further replies.

Share This Page