[commands] Add unless() decorator (#4244)

This commit is contained in:
ohowe
2022-05-24 10:22:19 -06:00
committed by GitHub
parent ef3714223b
commit b193b318c1
5 changed files with 77 additions and 2 deletions

View File

@@ -302,6 +302,18 @@ public interface Command {
return new ProxyScheduleCommand(this);
}
/**
* Decorates this command to only run if this condition is not met. If the command is already
* running and the condition changes to true, the command will not stop running. The requirements
* of this command will be kept for the new conditonal command.
*
* @param condition the condition that will prevent the command from running
* @return the decorated command
*/
default ConditionalCommand unless(BooleanSupplier condition) {
return new ConditionalCommand(new InstantCommand(), this, condition);
}
/**
* Schedules this command.
*