Skip to content

IEconomy

Namespace Mc.Scripting.Services · Kind interface

public interface IEconomy

An economy: balances of players (online or offline, by uuid), the transfers between them, and the currency. Provided by an economy plugin (Essentials is the first-party default, at a lower priority than any real economy). Without a provider, money rules must do nothing rather than invent money: check ServiceManager.TryGet for null. Thread: tick thread.

Member Description
Currency Currency { get; } The currency of the economy.
Currency Currency { get; }

The currency of the economy.

Member Description
long Balance(Uuid player) The balance in minor units; 0 for an unknown account.
EconomyResult Deposit(Uuid player, long minor, string reason) Adds money to an account.
bool Has(Uuid player, long minor) Whether the account holds at least the amount.
bool HasAccount(Uuid player) Whether the uuid has an account.
EconomyResult Transfer(Uuid from, Uuid to, long minor, string reason) Moves money from one account to another as one step: both or neither.
EconomyResult Withdraw(Uuid player, long minor, string reason) Takes money from an account, refusing to go below zero.
long Balance(Uuid player)

The balance in minor units; 0 for an unknown account.

Parameters

Name Type Description
player Uuid The player.

Returns long: The balance.

EconomyResult Deposit(Uuid player, long minor, string reason)

Adds money to an account.

Parameters

Name Type Description
player Uuid The player.
minor long The amount in minor units (positive).
reason string Why, for the provider’s log.

Returns EconomyResult: The result.

bool Has(Uuid player, long minor)

Whether the account holds at least the amount.

Parameters

Name Type Description
player Uuid The player.
minor long The amount in minor units.

Returns bool: True when the balance covers it.

bool HasAccount(Uuid player)

Whether the uuid has an account.

Parameters

Name Type Description
player Uuid The player (online or offline).

Returns bool: True when there is an account.

EconomyResult Transfer(Uuid from, Uuid to, long minor, string reason)

Moves money from one account to another as one step: both or neither.

Parameters

Name Type Description
from Uuid The paying player.
to Uuid The receiving player.
minor long The amount in minor units (positive).
reason string Why, for the provider’s log.

Returns EconomyResult: The result.

EconomyResult Withdraw(Uuid player, long minor, string reason)

Takes money from an account, refusing to go below zero.

Parameters

Name Type Description
player Uuid The player.
minor long The amount in minor units (positive).
reason string Why, for the provider’s log.

Returns EconomyResult: The result.

Member Description
event Action<Uuid?>? Changed Raised when an account’s balance changed (tick thread).
public event Action<Uuid?>? Changed;

Raised when an account’s balance changed (tick thread). A null uuid means many accounts may have changed.

Returns Action<Uuid?>?

Currency · EconomyResult · Uuid