🐛 Transition to AFTER_REGISTRATION even when no commands have been registered
This commit is contained in:
parent
7eddcd237a
commit
8913b2495e
5 changed files with 19 additions and 8 deletions
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -375,7 +375,7 @@ public class BukkitCommandManager<C> extends CommandManager<C> implements Brigad
|
|||
|
||||
final void lockIfBrigadierCapable() {
|
||||
if (this.minecraftVersion >= BRIGADIER_MINIMUM_VERSION) {
|
||||
this.transitionOrThrow(RegistrationState.REGISTERING, RegistrationState.AFTER_REGISTRATION);
|
||||
this.lockRegistration();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ public class CloudburstCommandManager<C> extends CommandManager<C> {
|
|||
RegistriesClosedEvent.class,
|
||||
CloudListener.INSTANCE,
|
||||
EventPriority.NORMAL,
|
||||
(listener, event) -> this.lock(),
|
||||
(listener, event) -> this.lockRegistration(),
|
||||
this.owningPlugin
|
||||
);
|
||||
}
|
||||
|
|
@ -89,10 +89,6 @@ public class CloudburstCommandManager<C> extends CommandManager<C> {
|
|||
return this.backwardsCommandSenderMapper.apply(sender).hasPermission(permission);
|
||||
}
|
||||
|
||||
final void lock() {
|
||||
this.transitionOrThrow(RegistrationState.REGISTERING, RegistrationState.AFTER_REGISTRATION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final @NonNull CommandMeta createDefaultCommandMeta() {
|
||||
return SimpleCommandMeta.builder().build();
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ public class VelocityCommandManager<C> extends CommandManager<C> implements Brig
|
|||
}
|
||||
|
||||
this.proxyServer.getEventManager().register(plugin, ServerPreConnectEvent.class, ev -> {
|
||||
this.transitionOrThrow(RegistrationState.REGISTERING, RegistrationState.AFTER_REGISTRATION);
|
||||
this.lockRegistration();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue