I tryed to make my own plugin and there is a error:
The type java.util.Optional cannot be resolved. It is indirectly referenced from required .class files
Can somebody help me pls (i´m a noob).
Mainclass:
package io.github.dommihd.testplugin;
import org.slf4j.Logger;
import org.spongepowered.api.Game;
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.event.game.state.GameStartedServerEvent;
import org.spongepowered.api.plugin.Plugin;
import org.spongepowered.api.text.Text;
import com.google.inject.Inject;
@Plugin(id = "testplugin", name = "Test Plugin", version = "1.0")
public class TestPlugin {
public static Game game;
public static TestPlugin test;
@Inject
private Logger logger;
public Logger getLogger()
{
return logger;
}
@Listener
public void onServerInit(GameInitializationEvent event)
{
getLogger().info("Plugin loading...");
test = this;
game = Sponge.getGame();
CommandSpec testCommandSpec = CommandSpec.builder()
.description(Text.of("Test Command"))
.permission("testplugin.command.test")
.executor(new TestCommand())
.build();
game.getCommandManager().register(this, testCommandSpec,"test");
}
}
CommandExecutor:
package io.github.dommihd.testplugin;
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("Test"));
return null;
}
CommandResult result = CommandResult.builder()
.successCount(1)
.build();
}