Sponge on Mac
Recently I began to try to program SpongePlugins on my MacBook. Therefor I created a sponge server and an example plugin. In the plugin I defined a Logger and in the onInitialize(GameInitializationEvent event)
method I tried to log a message. As I started the server after building the Jar via Gradle into the mods folder, but as i started the server nothing happened. A /test
command didn’t work and wasn’t even registered. Starting the plugin on a windows machine did work and the log and the command were executed. I don’t know any reason of the issue, I tried to export the plugin manually, nothing works. Now I want to know, if this is my fault or if not, if there will be any fix of this. I can send further informations if needed, I have no clue about this whole thing and I hope, one of the Sponge “Pros” will help. Thank you very much for your effort.
The following text contains the code:
The Main-Class code
package main;
import org.slf4j.Logger;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.command.spec.CommandSpec;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.game.state.GameInitializationEvent;
import org.spongepowered.api.plugin.Plugin;
import org.spongepowered.api.text.Text;
import com.google.inject.Inject;
@Plugin(id = "splittermon-plugin", name = "Splittermond Plugin", version = "0.0.0-DEV")
public class ExamplePlugin {
// -#- Logger -#-
@Inject
private Logger logger;
public Logger getLogger() {
return logger;
}
@Listener
public void onInitialization(GameInitializationEvent event) {
logger.info("Loading. . .");
CommandSpec spec = CommandSpec.builder()
.description(Text.of("Test command"))
.executor(new TestCommand())
.build();
Sponge.getCommandManager().register(this, spec, "test");
logger.info("Done.");
}
}
The TestCommand
package main;
import org.spongepowered.api.command.CommandException;
import org.spongepowered.api.command.CommandResult;
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.command.args.CommandContext;
import org.spongepowered.api.command.spec.CommandExecutor;
import org.spongepowered.api.text.Text;
public class TestCommand implements CommandExecutor{
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
src.sendMessage(Text.of(args));
return CommandResult.success();
}
}