Add support for registering subcommands by instance.
This commit introduces a new `register()` method on the CommandHandler class to allow registering pre-instantiated subcommands. This means that subcommands are no longer restricted in terms of instantiation, so they can have their dependencies injected at creation, rather than having to resort to Singleton anti-pattern means. Also refactors the existing internal MobArena command registration to use the new method to "drink our own champagne" and to reuse the code. Fixes #675
This commit is contained in:
@@ -11,6 +11,9 @@ These changes will (most likely) be included in the next version.
|
||||
|
||||
|
||||
## [Unreleased]
|
||||
### Added
|
||||
- (API) MobArena's internal command handler now supports registering pre-instantiated subcommand instances. This should make it easier for extensions to avoid the Singleton anti-pattern for command dependencies.
|
||||
|
||||
### Changed
|
||||
- The regex pattern for the player list command is now less greedy, so it will only match on `/ma players`, `/ma playerlist`, and `/ma player-list`. The previous pattern matched on anything that starts with `player`, which rendered the `/ma player-stats` command in MobArenaStats impossible to invoke.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user