Skip to content

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

Description

@wangzhizhou

Bug description

EzShops crashes on startup with a NullPointerException when Vault is installed but no economy provider (e.g. EssentialsX, CMI) has registered a Vault Economy service.

java.lang.NullPointerException: economy
    at com.skyblockexp.ezshops.bootstrap.PlayerShopComponent.<init>(PlayerShopComponent.java:58)
    at com.skyblockexp.ezshops.bootstrap.EzShopsBootstrap.start(EzShopsBootstrap.java:99)

Root cause

EzShopsBootstrap.setupEconomy() has a fallback that returns true when getPlugin("Vault") != null, even when getRegistration(Economy.class) == null:

if (getRegistration(Economy.class) == null && getPlugin("Vault") == null) return false;
// ...
economy = registration.getProvider(); // registration is null -> NPE later
return true;

The economy field stays null, and PlayerShopComponent's constructor throws on Objects.requireNonNull(economy).

Expected behaviour

Like the existing missing-Vault case, the plugin should log a clear message ("no Vault economy provider registered") and disable itself cleanly, instead of crashing with an unhandled NPE.

Fix

Branch fix/bootstrap-economy-npe on fork OrzMC/EzShops:

  • setupEconomy() checks getRegistration(Economy.class) first and returns false (clean disable) when no provider is registered, with a helpful log line.
  • Adds regression tests covering both "provider registered" and "Vault present but no provider" (MockBukkit).
  • While touching PlayerShopComponent, the non-fatal DB-fallback logs (Jaloquent / MySQL) are downgraded from SEVERE to WARNING so a missing remote DB no longer logs at error level.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions