Refactor Vault economy integration.
This commit reworks how MobArena interfaces with Vault economy provider instances. Instead of affixing an Economy _instance_ to the main plugin at "setup time", we create an instance of the new _Finance_ abstraction at "(re)load time", and then use this new abstraction at every call site (really just the MoneyThing) instead of Economy. This accomplishes two important things: 1. Due to how the Bukkit load order works and how Vault providers are registered with the plugin, the Finance abstraction gives us a means of deferring the retrieval of the Economy provider needed to integrate with the underlying economy plugin (or script). MobArena still uses Finance as if it was a "complete" object and is completely unaware of what goes on under the hodd. This is a much more elegant solution compared to the terrible past proposals of fragmenting MobArena's bootstrapping phase, especially considering the past proposals were server tick-centric... 2. It creates a simple and maintainable interface between MobArena and Vault, effectively giving control back to MobArena as to how everything should mesh together. The biggest downside to this solution is that we no longer know if an economy provider is available for when we need it at a convenient time in the startup process. Instead, we need to react accordingly when an economy operation is invoked. The implementation takes a somewhat mild approach by simply _logging_ any issues encountered and defaulting to "best effort" operations when an economy provider is not available. At worst, this is a bunch of log spam and potentially a lot of work for server owners to clean up after (compensating players for rewards and stuff like that), but MobArena doesn't handle arbitrary exceptions in its join/leave and start/end procedures very well, so it's probably a better way to go about it than throwing exceptions. If the server does not have Vault installed, an UnsupportedFinance is created. This implementation just logs errors and "fails to work" on every operation. If Vault is installed, a VaultFinance is created, and this implementation should only log errors if a Vault economy provider couldn't be found. We could have opted for a single implementation, but this approach allows us to potentially support other economy registrars in the future, so we (probably) won't have to make sweeping changes in order to swap to something else. Closes #797
This commit is contained in:
@@ -11,6 +11,9 @@ These changes will (most likely) be included in the next version.
|
||||
|
||||
|
||||
## [Unreleased]
|
||||
### Added
|
||||
- MobArena now properly supports Vault economy providers registered after MobArena has started. This should make it possible to use custom economy providers that aren't built into Vault, such as those created with Denizen.
|
||||
|
||||
### Changed
|
||||
- Recurrent waves can now be randomized. If two or more recurrent waves clash on wave number, frequency, _and_ priority, MobArena will now randomly pick between them. This should make it easier to create more varied and interesting wave setups without having to resort to only massively randomized default waves.
|
||||
- Single waves can now be randomized. If two or more single waves clash on wave number, MobArena will now randomly pick between them. This means it is now possible to make randomly selected bosses for boss waves, for instance.
|
||||
|
||||
Reference in New Issue
Block a user