Do I need to check the command?

Discussion in 'Plugin Development' started by JazzaG, Sep 16, 2012.

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

    JazzaG

    I'm too tired and lazy to test this, so hopefully you can answer it.

    If I have a class dedicated to executing a command, and I set the executor in my plugin's onEnable() method, do I have to check that the command equals the command?

    For example:

    Main class
    Code:
    @Override
    public void onEnable() {
        getCommand("command").setExecutor(new Commandthingy());
    }
    
    The executor
    Code:
    public class Commandthingy implements CommandExecutor {
     
    @Override
    public boolean onCommand(...) {
       
        // Not checking if command.getName().equalsIgnoreCase("command") because yolo
     
        if(!(sender instanceof Player)) {
            sender.sendMessage("players");
            return true;
        }
     
        // the rest of command logic
    }
     
    }
    
    In my command class, I didn't check if the command matches what I want it to, but seeing as I specified the executor in onEnable(), does that mean I don't have to?
     
  2. Offline

    Timr

    Short answer: No
    Long answer: see short answer
     
  3. Offline

    Muddr

    I'm too tired and lazy to answer this, so hopefully you can test it. <<< see what I did there.
     
    JazzaG likes this.
Thread Status:
Not open for further replies.

Share This Page