✨ Add a ManagerSetting to override existing commands
This commit is contained in:
parent
1ff5a2c4ce
commit
ded94567c6
3 changed files with 15 additions and 1 deletions
|
|
@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
handled using `CommandManager#registerExceptionHandler`, similar to `NoSuchCommandException`, `ArgumentParseException`, etc.
|
handled using `CommandManager#registerExceptionHandler`, similar to `NoSuchCommandException`, `ArgumentParseException`, etc.
|
||||||
- Added registration state to command managers
|
- Added registration state to command managers
|
||||||
- Added ALLOW_UNSAFE_REGISTRATION ManagerSetting to disable state checks when registering commands
|
- Added ALLOW_UNSAFE_REGISTRATION ManagerSetting to disable state checks when registering commands
|
||||||
|
- Added OVERRIDE_EXISTING_COMMANDS ManagerSetting to allow for overriding of existing commands on supported platforms
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Allow for use of `@Completions` annotation with argument types other than String
|
- Allow for use of `@Completions` annotation with argument types other than String
|
||||||
|
|
|
||||||
|
|
@ -870,7 +870,14 @@ public abstract class CommandManager<C> {
|
||||||
*
|
*
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*/
|
*/
|
||||||
ALLOW_UNSAFE_REGISTRATION
|
ALLOW_UNSAFE_REGISTRATION,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables overriding of existing commands on supported platforms.
|
||||||
|
*
|
||||||
|
* @since 1.2.0
|
||||||
|
*/
|
||||||
|
OVERRIDE_EXISTING_COMMANDS
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
package cloud.commandframework.bukkit;
|
package cloud.commandframework.bukkit;
|
||||||
|
|
||||||
import cloud.commandframework.Command;
|
import cloud.commandframework.Command;
|
||||||
|
import cloud.commandframework.CommandManager;
|
||||||
import cloud.commandframework.arguments.CommandArgument;
|
import cloud.commandframework.arguments.CommandArgument;
|
||||||
import cloud.commandframework.arguments.StaticArgument;
|
import cloud.commandframework.arguments.StaticArgument;
|
||||||
import cloud.commandframework.internal.CommandRegistrationHandler;
|
import cloud.commandframework.internal.CommandRegistrationHandler;
|
||||||
|
|
@ -89,6 +90,11 @@ public class BukkitPluginRegistrationHandler<C> implements CommandRegistrationHa
|
||||||
this.bukkitCommandManager
|
this.bukkitCommandManager
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (this.bukkitCommandManager.getSetting(CommandManager.ManagerSettings.OVERRIDE_EXISTING_COMMANDS)) {
|
||||||
|
this.bukkitCommands.remove(label);
|
||||||
|
aliases.forEach(alias -> this.bukkitCommands.remove(alias));
|
||||||
|
}
|
||||||
|
|
||||||
for (final String alias : aliases) {
|
for (final String alias : aliases) {
|
||||||
final String namespacedAlias = this.getNamespacedLabel(alias);
|
final String namespacedAlias = this.getNamespacedLabel(alias);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue