Error running command: This command must be executed by a player! in sponge 8.0

I want to force player execute command /spawn so I make this code.

Sponge.server().commandManager().process(player, “spawn”);

then in command show an error.

Caused by: org.spongepowered.common.command.exception.SpongeCommandSyntaxException: Error running command: This command must be executed by a player!

How can I force player execute the command without error ?

the /spawn command is from “nuclesus” plugin.

Please help me.

So what you have got there is the official way of running a command as a player whereby you have set the source and the audience to be the player.

However.

Nucleus does something different to check if a player sent the command. Not sure if it was a api 7 thing or just a work around for a early api 8 and never got updated before nucleus stopped getting updates. But nucleus checks the root of the command cause.

As far as im aware, you cannot change the command cause before running a command. So this lands you in hacky work arounds (such as hooking into nucleus and getting the spawn location then teleporting the player yourself)

However due to the fact nucleus isnt being maintained, I personally would wait for someone to take on the essentials plugin role (could be waiting for the plugin competition that was mentioned on SOS)

1 Like

Thank for you care!