VaultHook
Vault Economy integration — balance, withdraw, deposit by UUID, sink account, and amount formatting.
Based on GrzybcioRynek 1.0.3 and web 0.1.0 source.
VaultHook is required. Without the Vault plugin or without a RegisteredServiceProvider<Economy>, the plugin disables (after one retry in 1 s).
Startup
setupEconomy():
getPlugin("Vault") == null→ warningVault nie znaleziono! Plugin nie będzie działać.→enabled = false.ServicesManager.getRegistration(Economy.class) == null→Nie znaleziono providera ekonomii!.- Success:
Pomyślnie połączono z Vault!.
isEnabled() = enabled && economy != null.
MarketPlace.onEnable on first fail logs Economy jeszcze niedostępna — ponawiam za 1s (Essentials/Vault)... and calls the constructor again after 20 ticks. Second fail: Vault nie znaleziono lub brak providera ekonomii! Wyłączanie pluginu.
plugin.yml: depend: [Vault], softdepend: [..., Essentials]. Essentials has no hook class — only late-load Economy timing.
Methods
| Method | Behavior |
|---|---|
getBalance(OfflinePlayer) | economy.getBalance; when disabled → 0 |
has(OfflinePlayer, amount) | economy.has after normalizeAmount |
withdraw(OfflinePlayer, amount) | withdrawPlayer; amount <= 0 → false |
deposit(OfflinePlayer, amount) | delegates to deposit(player, amount, null) |
deposit(OfflinePlayer, amount, sellerName) | only depositPlayer(player, amount) by UUID |
depositAccount(String, amount) | depositPlayer(accountName, amount) — fee sink |
format(double) | $123 or $123.45 (not Vault format) |
Amounts are rounded: Math.round(amount * 100.0) / 100.0. Deposit <= 0 returns true (no-op).
No nickname fallback
depositToSeller only calls economy.depositPlayer(player, amount). When that fails, even with a valid sellerName:
Vault deposit po UUID nieudany dla <uuid> (<error>) — NIE używam fallbacku po nicku.sellerName is only for logs (resolveTargetName). The value "Nieznany" is rejected as a name.
Fail withdraw/deposit/deposit-account:
Vault <type> nie powiodlo sie dla <target> (<amount>): <errorMessage>type is withdraw, deposit, or deposit-account.
Fees and sink
ConfigManager.calculateSaleFee / calculateListingFee — percent, then minimum-fee, then maximum-fee when > 0. market-fee.enabled: false → both fees = 0.
After SELLER_PAID, if fee > 0 and market-fee.sink-account is non-empty: depositAccount(sink, fee). Fail does not roll back the purchase — only a warning:
Nie udało się wpłacić prowizji <fee> na konto sink '<sink>'.Empty sink-account = the fee is burned (returned to nobody).
Format in PAPI and GUI
PlaceholderHook (total_spent, total_earned, market_volume) and market messages use VaultHook.format, not Vault’s native format.