Karthannar

Server modloader and nulls

Recommended Posts

Is there a way to get around this?

SEVERE org.gotti.wurmunlimited.modsupport.actions.WrappedBehaviour: null
java.lang.NullPointerException
        at org.karth.wurmunlimited.mods.spookycreatures.KarthUtils.getVillageNum(KarthUtils.java:74)
        at org.karth.wurmunlimited.mods.spookycreatures.actions.GenericActions.action(GenericActions.java:69)
        at org.gotti.wurmunlimited.modsupport.actions.ActionPerformerBehaviour.action(ActionPerformerBehaviour.java:82)
        at org.gotti.wurmunlimited.modsupport.actions.WrappedBehaviour.lambda$action$9(WrappedBehaviour.java:102)
        at org.gotti.wurmunlimited.modsupport.actions.WrappedBehaviour.action(WrappedBehaviour.java:211)
        at org.gotti.wurmunlimited.modsupport.actions.WrappedBehaviour.action(WrappedBehaviour.java:102)
        at org.gotti.wurmunlimited.modsupport.actions.ActionPerformerChain.action(ActionPerformerChain.java:77)
*snip*

Basically I'm trying to call "getVillage().getDeedId()" but whenever I'm not on a tile that's part of a deed it tries to spit out a null value which causes the above. I've tried quite a bit and I can't figure out how to get around that. Anyone better at this than me have any insight?

Edited by Karthannar

Share this post


Link to post
Share on other sites
if (vt.getVillage()!=null) {
	// do whatever you need with the village
} else {
	// handle case when not on village
}

 

Share this post


Link to post
Share on other sites

*smacks forehead*

 

Of course it was that simple, thank you @bdew!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now