Solved Command usage through console

Discussion in 'Plugin Development' started by Phishy, Feb 23, 2015.

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

    Phishy

    Hi, On trying to execute a command through the console, it throws a stack trace at me:

    What is the code for getting if the command is made my the console?
     
  2. Offline

    MajorSkillage

    CommandSender Sender;
    if(Sender instanceof ConsoleSender){

    }
     
  3. Offline

    MrGussio

    Well, it is just possible with onCommand.


    Code:
    public boolean onCommand(CommandSender sender, Command cmd, String label, String args[]){
    if(cmd.getName().equalsIgnoreCase("hello"){
    sender.sendMessage("Hello World!");
    return true;
    }
    return false;
    }
    Then there will be a message in the console, it's just the same way as you want to process player commands.
     
  4. Offline

    Phishy

    Exactly what I was looking for, forgot about sender. , lol, anyway, thanks alot
     
  5. Offline

    MajorSkillage

    "my the console" lol typo my is meant to = by :p
     
  6. Offline

    MrGussio

    No problem dude :)
     
  7. Offline

    MajorSkillage

    Put this as solved my good sir! :)
     
Thread Status:
Not open for further replies.

Share This Page