IEconomy
Namespace Mc.Scripting.Services · Kind interface
public interface IEconomyAn 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.
Properties
Section titled “Properties”| Member | Description |
|---|---|
Currency Currency { get; } |
The currency of the economy. |
Currency
Section titled “Currency”Currency Currency { get; }The currency of the economy.
Methods
Section titled “Methods”| 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. |
Balance
Section titled “Balance”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.
Deposit
Section titled “Deposit”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.
HasAccount
Section titled “HasAccount”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.
Transfer
Section titled “Transfer”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.
Withdraw
Section titled “Withdraw”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.
Events
Section titled “Events”| Member | Description |
|---|---|
event Action<Uuid?>? Changed |
Raised when an account’s balance changed (tick thread). |
Changed
Section titled “Changed”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?>?