Help! My first plugin with commands got errors.

Discussion in 'Plugin Development' started by streedie, Jun 12, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    streedie

    So... hey guys,
    Haven't got many topics here. But I got some errors in Eclipse IDE.
    I get this error:
    Code:
    FSObjectionCommand cannot be resolved to a type
    And this is the part of the code:
    Code:
    getCommand("Over").setExecutor(new FSOverCommand(this));
    getCommand("Objection").setExecutor(new FSObjectionCommand(this));
    getCommand("Nice").setExecutor(new FSNiceCommand(this));
    PLEASE HELP!
     
  2. Use onCommand instead.
     
  3. Offline

    streedie

    Still doesn't work.
     
  4. Offline

    Acrobot

    Did you create your FSObjectionCommand with constructor?
     
  5. Offline

    ZephyrSigmar

    Why do you use three command executor?
    You should use one,and set it to execute all the commands in it.
    Make sure you added implements CommandExecutor after the class name and make sure you added this code inside your commandexecutor:
    Code:
    private final yourpluginsmainclassnamehere plugin;
    public commandexecutornamehere(yourpluginsmainclassnamehere plugin){
    this.plugin=plugin;
    }
    Make sure you replace my code's parts with your stuff name.
     
  6. Offline

    streedie

    Giving me more errors.
     
  7. Offline

    Baummann

    just put this in your main class:

    Code:
    public boolean onCommand(CommandSender sender, Command cmd, String cmdLine, String[] split) {
       if (cmd.getName().equalsIgnoreCase("yourcommandhere")) {
       if (sender instanceof Player) {
           Player player = (Player) sender;
           //do stuff
       }
       }
       return false;
    }
     
  8. Offline

    CptSausage

    Because it's comfortable and Dinnerbone showed it in an example (click).


    To use commands make sure you:
    • Define them in the yml
    • Create a Command Executor class, which implements... guess what: CommandExecutor
    • Create the "onCommand" Method in your Command Executor class (Normally not in your main), if Eclipse didn't already.
    • Register your commands in the "onEnable" Method in your main class, as you are already doing.
    Have a look into Dinnerbone's example. At least this is how it works for me :D
     
  9. Offline

    streedie

    All did this. The command thing does work now.
    Now got some error with simple fix: Update code to newest.
    Edit: If I have <command> [shout] ín the everywhere, it won't.
    EditEdit: 1 problem, I see the command under the text.
     
Thread Status:
Not open for further replies.

Share This Page