[SOLVED]Difficulties returns null

So is this something that hasn’t been implemented yet? All properties in the Difficulties class return null.

They’re not null at runtime.

1 Like

Maybe this will help.

They’re not null at runtime.

1 Like

Ok let me start over. I’m trying to set to difficulty of a world via command, and the above for-mentioned is giving me grief. Here’s one example below. No matter how I approach it I get a null value when attempted to create a Difficulty object.

Difficulty difficulty = Main.getGame().getRegistry().getType(Difficulty.class, "NORMAL").get();
world.getProperties().setDifficulty(difficulty);

also tried this, thinking the above getType was not working the way I assumed.

world.getProperties().setDifficulty(Difficulties.NORMAL);

That will work, as they’re not null at runtime.

The registry depends on stuff being implemented, but generally it should work as well.

Nevermind, blame @gabizou

So it’s not my fault…?

No. The Difficulties class was not being registered at runtime (because our registry system handles all of them and someone forgot an annotation), but it should be working if you depend on the latest SpongeCommon locally. There’s a few things that are still being fixed for the next SpongeForge build, but it will be there.

Awesome. Thanks for putting up with my ignorance and appreciate the quick resolution.

However in short though, the API can’t dictate any of the CatalogType instances as “available” since many of them depend on implementation classes, so at runtime (when everything is being run), they will NOT be null. However, at compile time, they are null.