Nullpointer

Discussion in 'Plugin Development' started by Laekh, Jul 24, 2013.

Thread Status:
Not open for further replies.
  1. Hi!

    I'm getting this nullpointer, and I have NO idea where it comes from.

    Code:
    EntityType villager = EntityType.VILLAGER;
    LivingEntity vi = (LivingEntity) Bukkit.getWorld("world").spawnEntity(loc, villager);
    
    The nullpointer is pointing to that second line, I tried replacing the getworld with the multiverse core API one, that didn't change anything..

    Thank you.
     
  2. Offline

    Pawnguy7

    First, you could have the entitytype inline - that is, spawnEntity(loc, EntityType.VILLAGER). That isn't the problem though.

    Could it be loc is null?
     
  3. Offline

    Chinwe

    You sure that 'world' exists? Try using loc.getWorld() instead (more useful in the future too)

    loc could be null too, make sure its initialized :)

    EDIT: Semi ninja'd by Pawnguy7 :oops:
     
  4. The world was a very specific one, just changed it so people would see what I meant :p it wouldn't be used for any others, but I went ahead and changed it anyways.

    So I did as told, and still got it. I've just split the line into 5 parts to see where it's coming from.
    seems to come from something different which I didn't include here.

    Thank you though!
     
Thread Status:
Not open for further replies.

Share This Page