Solved Getting a location is returning null

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

  1. Offline

    Shadow_tingBRO

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

    Shadow_tingBRO

    @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

Share This Page