[Solved] Can't get World getting to work. Please help!

Trying to develop plugin but can’t move one because world getting doesn’t work in SpawnCmd Class.
Files are in the link in the description.
Please help.
Thank you, Jacob

https://github.com/KubqoA/Spongi

Any error logs?

https://github.com/KubqoA/Spongi/blob/master/src/main/java/me/kubqoa/spongi/SpongiMain.java#L72
You shouldn’t add the quotes (")

What exactly is the issue? I couldn’t understand what you said above

I don’t know for certain, it was a bit of a guess.

Using the information provided:

I took this to mean that the call to getWorld() isn’t working right here:
https://github.com/KubqoA/Spongi/blob/master/src/main/java/me/kubqoa/spongi/Commands/SpawnCmd.java#L43

So on inspecting the variable worldname, the world name comes from the config directly:
worldname = rootNode.getNode("spawn","world").getString();
Then I looked at where the spawn.world config node is set. As I linked in my previous reply, the line:
rootNode.getNode("spawn","world").setValue("\""+game.getServer().getWorld("world").get().getName()+"\"");
is what sets that config value.
The issue is that there should not be quotes around the name (see the "\"" + ... + "\""). They should not be there.

But @KubqoA needs to provide more information for me to be certain what the problem is.

So i update the source so it loads now.

Error log:

Note: i edited spongi.conf myself so the problem with bad init of config file is not important

Posted there also .jar file

Their is a reason why Optional<World> getWorld(String Name) returns an optional. You shouldn’t invoke getworld().get() that would totally destroy this awesome pattern :frowning:. What you shouldn’t do is something like this:

Optional<World> world = server.getWorld(name);
if (world.isProvided()){
  world.get().dostuff(); //fictive method
}
else{
  logger.info("Error Could not find world: " + name);
}

Do you mean i should or shouldn’t?

So i updated the content with code your part of code and it didn’t work. I don’t know what to do so please help.
Updated code can be found on https://github.com/KubqoA/Spongi and log here: http://pastebin.com/fFkV5raP

Note: there is no such thing as isProvided() so i used isPresent()

1 Like

That game2 Field doesn’t get injected, so it stays null
I suggest you pass the game instance as Constructor parameter to the SpawnCmd instead of using a static method to access it.

https://github.com/KubqoA/Spongi/blob/master/src/main/java/me/kubqoa/spongi/SpongiMain.java#L53
=> .executor(new SpawnCmd(game))

1 Like

Okay and when i pass it to it how to use it then?

just save it in a field in SpawnCmd

gonna test it now

Oh thanks man it worked! I am so glad you helped me. OMG i am so thankful :smile:

Okay it can now be marked as solved thanks Faithcaio

Just edit the title and add [solved] ;).