SpongePowered / SpongeAPI

A Minecraft plugin API
http://www.spongepowered.org/
MIT License
1.14k stars 342 forks source link

Cannot resolve symbol 'getCommandManager' #2201

Closed ToukiiWoulkie closed 4 years ago

ToukiiWoulkie commented 4 years ago

Hello everyone, I have an issue with the command manager (im pretty new to sponge)

package fr.tokiiwalkie.planisphere;

import com.google.inject.Inject;
import org.slf4j.Logger;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.command.CommandManager;
import org.spongepowered.api.command.spec.CommandSpec;
import org.spongepowered.api.event.game.state.GameStartedServerEvent;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.plugin.Plugin;
import org.spongepowered.api.plugin.PluginManager;
import org.spongepowered.api.text.Text;

@Plugin(
        id = "planisphere",
        name = "Planisphere",
        description = "The main plugin for the server \"Planisphère\"",
        authors = {
                "TokiiWalkie"
        }
)
public class Main {

    @Inject
    private Logger logger;

    @Inject
    private PluginManager pluginManager;

    @Listener
    public void onServerStart(GameStartedServerEvent event) {
        logger.info("Planisphere works :p");
    }

    CommandSpec myCommandSpec = CommandSpec.builder()
            .description(Text.of("Hello world command"))
            .permission("planisphere.command.helloworld")
            .executor(new HelloWorldCommand())
            .build();

    Sponge.getCommandManager() [...]
    // So there i cannot make the code correctly 'cuz intellij tells me that "Cannot resolve symbol 'getCommandManager'"
}
dualspiral commented 4 years ago

Github issues are for reporting bugs and requesting features in Sponge. As this issue is a request for support, I am closing this issue.

The following resources are available to support you in using and developing for Sponge:

However, based on your issue here, it looks like you are also new to Java and/or programming in general. We encourage you to look at some of these resources to help you with Java so that you can develop for Sponge more effectively.

dualspiral commented 4 years ago

(to give you a hint, you will want Sponge.getCommandManager() to be inside a method, it isn't there.)