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. Offline


    This has been annyoing me for a looong time now. When I try access a location from this 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

    I made a testing command and did:

    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. Online

    timtower Ninja on the waves 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. Offline


    @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