Skip to content

fix(bootstrap): disable cleanly when Vault has no economy provider - #82

Open
wangzhizhou wants to merge 1 commit into
ez-plugins:mainfrom
OrzMC:fix/bootstrap-economy-npe
Open

fix(bootstrap): disable cleanly when Vault has no economy provider#82
wangzhizhou wants to merge 1 commit into
ez-plugins:mainfrom
OrzMC:fix/bootstrap-economy-npe

Conversation

@wangzhizhou

Copy link
Copy Markdown

Summary

Fixes #79 — EzShops no longer crashes with a NullPointerException on startup when Vault is present but no economy provider is registered.

Changes

  • EzShopsBootstrap.setupEconomy(): check getRegistration(Economy.class) first; when no provider is registered, log a clear message ("Install an economy plugin that provides a Vault economy service") and return false so the plugin disables itself cleanly.
  • PlayerShopComponent: downgrade the non-fatal DB-fallback logs (Jaloquent / MySQL connection failures) from SEVERE to WARNING.
  • Tests (EzShopsSetupEconomyFeatureTest): cover both "economy provider registered → plugin enables" and "Vault present but no provider → plugin disables cleanly".

Testing

  • Local (MockBukkit tests skipped by version assumption): mvn test -Dpaper.version=1.21.3-R0.1-SNAPSHOT
  • Full MockBukkit run: mvn test -Dpaper.version=1.21.11-R0.1-SNAPSHOT — both new tests pass.

Closes #79

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] NullPointerException on startup when Vault has no economy provider

1 participant