Skip to content

[Feature]: Allow plugins to provide the economy used for upgrade purchases #8

Description

@Crispi2k24

What problem would this solve?

Upgrade costs go through UpgradePayment, which takes the Vault bridge and nothing else.
On a server without Vault - or with a currency that is not Vault money, like a per-island
balance - withdraw() returns false and every click on an upgrade is refused. formatCost
also falls back to amount.toPlainString(), so the price in the panel is unformatted.

The API already solves this for the other half of the economy: MinionShopService
.registerProvider lets a plugin supply prices and payouts for the seller minion. There is
no equivalent for what a minion costs to upgrade.

The only way out today is to cancel MinionUpgradePurchaseEvent, charge the player and
apply the tier through MinionManagementService#setUpgradeTier. That works, but cancelling
makes purchase() return an empty Optional, so callers cannot tell "the player could not
afford it" from "another plugin handled it" - and anything that refreshes on the returned
value silently stops working.

What would you like to happen?

A registration point for upgrade payments, mirroring MinionShopService#registerProvider:

MinionUpgradeEconomyService.registerProvider(Plugin, MinionUpgradeEconomyProvider)

MinionUpgradeEconomyProvider
- boolean available()
- boolean withdraw(UUID playerId, BigDecimal amount)
- String format(BigDecimal amount)

UpgradePayment would use the registered provider when there is one and fall back to Vault
otherwise, so nothing changes for servers that use Vault today.

That removes the reason to cancel MinionUpgradePurchaseEvent, and the event goes back to
meaning "veto this purchase" rather than "take it over".

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions