org.bukkit.craftbukkit.v1_4_R1.CraftServer.getWorld(CraftServer.java:811)

Discussion in 'Plugin Development' started by xXSniperzzXx_SD, Jan 30, 2013.

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

    xXSniperzzXx_SD

    So a few of my users have been getting this error, It's not a constant one, it will happen the odd time, and the only way to fix it is to set the world's name again. Read the bottom of the post for more info.
    Here is the full error:
    And this is the method it's referring to

    Code:java
    1. @SuppressWarnings("deprecation")
    2. public static void tp2LobbyAfter(Player player){
    3. if(!Main.db.getBlocks().isEmpty()){
    4. for(Location loc : Main.db.getBlocks().keySet()){
    5. loc.getBlock().setType(Main.db.getBlocks().get(loc));
    6. }
    7. }
    8. Main.db.getBlocks().clear();
    9. if(Bukkit.getServer().getWorld(Main.config.getString("Lobby.World"))==null){
    10. player.sendMessage(Main.I+ChatColor.RED+"Infected was unable to find the lobbies world, please inform a admin to reset the lobby's location!");
    11. resetp(player);
    12. resetInf();
    13. if(Main.config.getBoolean("End Game On Error")){
    14. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "Infected Admin Shutdown");
    15. }
    16. }else{
    17. World world = Bukkit.getServer().getWorld(Main.config.getString("Lobby.World"));
    18. player.teleport(new Location(world, Main.config.getInt("Lobby.X"), Main.config.getInt("Lobby.Y")+.5, Main.config.getInt("Lobby.Z")));
    19. resetPlayersInventory(player);
    20. if(Infected.filesGetShop().getBoolean("Save Items")) player.getInventory().setContents(Infected.playerGetShopInventory(player));
    21. Main.Lasthit.remove(player.getName());
    22. player.setGameMode(GameMode.ADVENTURE);
    23. player.updateInventory();
    24. Main.Votes.clear();
    25. Main.inLobby.add(player.getName());
    26. Main.zombies.clear();
    27. Main.humans.clear();
    28. Main.Tanks.clear();
    29. player.setHealth(20);
    30. player.setFoodLevel(20);
    31. Main.KillStreaks.remove(player.getName());
    32. Main.Booleans.put("Started", false);
    33. Main.Booleans.put("BeforeGame", false);
    34. Main.Booleans.put("BeforeFirstInf", false);
    35. Main.Voted4.clear();
    36. Bukkit.getServer().getScheduler().cancelTask(Main.timestart);
    37. Bukkit.getServer().getScheduler().cancelTask(Main.timeLimit);
    38. Bukkit.getServer().getScheduler().cancelTask(Main.timeVote);
    39. Bukkit.getServer().getScheduler().cancelTask(Main.queuedtpback);
    40. if(Main.config.getBoolean("DisguiseCraft Support"))
    41. if(Main.dcAPI.isDisguised(player) == true)
    42. Main.dcAPI.undisguisePlayer(player);
    43. if(Main.inGame.size()==0)
    44. Main.Winners.clear();
    45. }
    46. }


    The line the error refers to is:

    Code:java
    1. if(Bukkit.getServer().getWorld(Main.config.getString("Lobby.World"))==null){

    ________________________________________________________________

    But the thing that confuses me is that, the world name is correct in the config, and this doesn't happen every time, just the odd time. Does anyone know how to fix this? Or even to just prevent it.
     
  2. Offline

    EnvisionRed

    Set the string from the config to a string called worldName, then check if worldName is null. If it's not, then try getting the world with worldName.
     
  3. Offline

    ZachBora

    deja vu... add code that checks if "Main" and "Main.config" are null. I don't think "Bukkit" or "Bukkit.getServer()" could return null...
     
  4. Offline

    xXSniperzzXx_SD

    EnvisionRed
    Okay so that would be a way to prevent the error but then i just have to end the game because it can't find the string well it's there

    What i really want is a fix for this, not a way to make sure it's there... Anyone have any ideas?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  5. Offline

    ZachBora

    You could make your config work. Nothing tells me you correctly populate and depopulate Main.config. Check every place that it's assigned or deassigned/changed.
     
  6. Offline

    xXSniperzzXx_SD

    ZachBora
    It works... Everything else in it works. Like i said it doesn't happen all the time, it's just a odd occurance and usually you just have to reset the lobby's location to fix
     
  7. Offline

    ZachBora

    Add a server log output of the variable, this way you'll see what it was when it happens.
     
  8. Offline

    xXSniperzzXx_SD

    ZachBora
    Like i said before it works normally then just randomly(Been trying to avoid that word) it happens, no warnings or anything. Nothing in the config will be changed. (Although i haven't been able to get this bug on a server without NoCheatPlus, so might be related)
     
  9. Offline

    ZachBora

    I'm just trying to help but obviously you don't want it. It is a bug in your code. I stop helping and leaving this thread.
     
Thread Status:
Not open for further replies.

Share This Page