fix: retry Vault hook after addons enable#2995
Merged
Merged
Conversation
BentoBox hooks Vault during early hooks, before addons are enabled. An addon may register a Vault economy provider in its own onEnable (e.g. InvSwitcher, which provides per-world balances), after that early attempt already failed for lack of any economy. A failed hook is discarded by HooksManager, so getVault() stayed empty even though an economy now exists - leaving economy-dependent addons (e.g. Bank) unable to start. Re-attempt the Vault hook once after enableAddons() so an economy provided by an addon is picked up. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Problem
BentoBox registers its
VaultHookduring early hooks (BentoBoxHookRegistrar.registerEarlyHooks()), which runs beforeaddonsManager.enableAddons(). At that point no economy provider may be registered with Bukkit'sServicesManageryet, soVaultHook.hook()returnsfalse.HooksManager.registerHook()only stores hooks whosehook()succeeds, so a failed Vault hook is discarded entirely andgetVault()returns empty.This is a problem for addons that provide a Vault economy in their own
onEnable()— e.g. InvSwitcher, which registers a per-worldEconomyprovider so each game world has its own balance. Because BentoBox already gave up on Vault,getVault()stays empty even though a perfectly good economy now exists, and economy-dependent addons such as Bank disable themselves with "Vault is required".Fix
Re-attempt the Vault hook once, right after
enableAddons(), via a newBentoBoxHookRegistrar.registerVaultHookIfNeeded()(no-op if Vault is already hooked). Any economy an addon registered during enable is now picked up.This is a minimal, general safety net — it helps any addon that registers an economy in
onEnable, not just InvSwitcher.Notes
getVault()during their ownonEnable(like Bank) still need to either enable after the economy provider or retry the hook themselves; a companion PR to Bank does the latter. This PR fixes the general BentoBox-side gap.develop.🤖 Generated with Claude Code