fix(bootstrap): disable cleanly when Vault has no economy provider - #82
Open
wangzhizhou wants to merge 1 commit into
Open
fix(bootstrap): disable cleanly when Vault has no economy provider#82wangzhizhou wants to merge 1 commit into
wangzhizhou wants to merge 1 commit into
Conversation
setupEconomy() returned true whenever the Vault plugin was loaded, even when
Vault had not registered any Economy provider (no EssentialsX/CMI hooked in).
The null economy was then passed to PlayerShopComponent.<init>, which threw
NullPointerException: economy at startup instead of failing gracefully.
Since plugin.yml declares `depend: [Vault]`, the plugin can only reach
onEnable with Vault present, so the getPlugin("Vault") fallback was both
dead and harmful. Rely solely on the registered ServicesManager provider and
log a clear message before disabling the plugin when none exists.
Adds a MockBukkit regression test that loads a bare "Vault" plugin with no
economy provider and asserts EzShops disables without throwing.
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.
Summary
Fixes #79 — EzShops no longer crashes with a
NullPointerExceptionon startup when Vault is present but no economy provider is registered.Changes
EzShopsBootstrap.setupEconomy(): checkgetRegistration(Economy.class)first; when no provider is registered, log a clear message ("Install an economy plugin that provides a Vault economy service") and returnfalseso the plugin disables itself cleanly.PlayerShopComponent: downgrade the non-fatal DB-fallback logs (Jaloquent / MySQL connection failures) fromSEVEREtoWARNING.EzShopsSetupEconomyFeatureTest): cover both "economy provider registered → plugin enables" and "Vault present but no provider → plugin disables cleanly".Testing
mvn test -Dpaper.version=1.21.3-R0.1-SNAPSHOTmvn test -Dpaper.version=1.21.11-R0.1-SNAPSHOT— both new tests pass.Closes #79