Solved Getting a location is returning null

Discussion in 'Plugin Development' started by Shadow_tingBRO, May 4, 2019.

Thread Status:
Not open for further replies.
  1. This has been annyoing me for a looong time now. When I try access a location from this code:

    Code:
    private static final Location spawn = new Location(Bukkit.getWorld("kitpvp"),-836.5 , 100, -120.5);
    
    , I keep getting a NullPointerException but I have noo idea why.

    It must be the
    Code:
     Bukkit.getWorld("kitpvp")
    
    line.

    I made a testing command and did:

    Code:
    for(World w : Bukkit.getWorlds()) {
    
    p.sendMessage(w + "\n\n");
    
    }
    
    , it came up will all the CraftWorlds and the kitpvp world WAS there. along with others. Any ideas???
     
  2. Offline

    timtower Administrator Administrator Moderator

    @Shadow_tingBRO Make the spawn when you are sure that the world is fully loaded.
    Start by putting the line in the onEnable.
     
  3. @timtower ok let me test this.....

    thanks you works now!!!!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 4, 2019
Thread Status:
Not open for further replies.

Share This Page