🐛 Transition to AFTER_REGISTRATION even when no commands have been registered

This commit is contained in:
jmp 2021-01-02 14:57:38 -08:00 committed by Alexander Söderberg
parent 7eddcd237a
commit 8913b2495e
5 changed files with 19 additions and 8 deletions

View file

@ -852,6 +852,21 @@ public abstract class CommandManager<C> {
}
}
/**
* Transition the command manager from either {@link RegistrationState#BEFORE_REGISTRATION} or
* {@link RegistrationState#REGISTERING} to {@link RegistrationState#AFTER_REGISTRATION}.
*
* @throws IllegalStateException if the manager is not in the expected state
* @since 1.4.0
*/
protected final void lockRegistration() {
if (this.getRegistrationState() == RegistrationState.BEFORE_REGISTRATION) {
this.transitionOrThrow(RegistrationState.BEFORE_REGISTRATION, RegistrationState.AFTER_REGISTRATION);
return;
}
this.transitionOrThrow(RegistrationState.REGISTERING, RegistrationState.AFTER_REGISTRATION);
}
/**
* Get the active registration state for this manager.
* <p>

View file

@ -70,7 +70,7 @@ public abstract class LockableCommandManager<C> extends CommandManager<C> {
* Lock writing. After this, {@link #isCommandRegistrationAllowed()} will return {@code false}
*/
protected final void lockWrites() {
this.transitionOrThrow(RegistrationState.REGISTERING, RegistrationState.AFTER_REGISTRATION);
this.lockRegistration();
}
}