✨ Give CommandManager a registration state (#148)
* Make CommandManager track its availability for registration This prevents situations where changes to the manager would result in undefined state in other places. * Add unsafe registration capability * Very minor formatting + `@since` tags * Add changes to changelog Co-authored-by: Alexander Söderberg <sauilitired@gmail.com>
This commit is contained in:
parent
65684d0036
commit
013d2d61f4
11 changed files with 273 additions and 155 deletions
|
|
@ -95,6 +95,7 @@ public class PaperCommandManager<C> extends BukkitCommandManager<C> {
|
|||
*/
|
||||
@Override
|
||||
public void registerBrigadier() throws BrigadierFailureException {
|
||||
this.requireState(RegistrationState.BEFORE_REGISTRATION);
|
||||
this.checkBrigadierCompatibility();
|
||||
if (!this.queryCapability(CloudBukkitCapabilities.NATIVE_BRIGADIER)) {
|
||||
super.registerBrigadier();
|
||||
|
|
@ -133,6 +134,7 @@ public class PaperCommandManager<C> extends BukkitCommandManager<C> {
|
|||
* @see #queryCapability(CloudBukkitCapabilities) Check if the capability is present
|
||||
*/
|
||||
public void registerAsynchronousCompletions() throws IllegalStateException {
|
||||
this.requireState(RegistrationState.BEFORE_REGISTRATION);
|
||||
if (!this.queryCapability(CloudBukkitCapabilities.ASYNCHRONOUS_COMPLETION)) {
|
||||
throw new IllegalStateException("Failed to register asynchronous command completion listener.");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue