Toggle an EventHandler?

Discussion in 'Spigot Plugin Development' started by FlawlessGaming, May 5, 2017.

  1. I have this event handler that i want to have hooked up to a command. Is that possible and if so whatsthe code? I've tried and failed...
     
  2. Just make a boolean lol...
    Code (Text):
    if(!boolean) {
    return;
    }
    else if(boolean) {
    //CODE
     
  3. You don't event need the else if (boolean) since you return in the first if statement.
     
  4. Sorry, I was typing it real quick.
    @FlawlessGaming Maybe you can add the player to an arraylist to signify true and don't if false. It might be better than using a public boolean.
     
  5. That would make this per-player, which I don't think is what the OP wants. I'd just use a private variable with (possibly protected) getters and setters.
    And then in the command class, keep a reference to the event listener and invoke it's setter method with the appropriate value.