Creating Custom Account Statuses
Creating Custom Account Statuses for TheNewEconomy
Account statuses in TheNewEconomy allow you to define the rules for how accounts can interact with funds. Custom account statuses can restrict or enable actions such as receiving funds, using balances, or being unlocked with a PIN.
Overview of AccountStatus
The AccountStatus
interface defines the behavior of account statuses. Each status must implement the following methods:
identifier()
: Returns a unique identifier for the status.unlockable()
: Indicates if the status can be unlocked using the account's PIN.use()
: Specifies if the account can use funds.receive()
: Specifies if the account can receive funds.
Example: Implementing a Custom Status
Below is an example of a custom FrozenStatus
, which blocks all actions:
Example: Default Account Statuses in TNE
Normal Status
Identifier:
normal
Unlockable: No
Can Use Funds: Yes
Can Receive Funds: Yes
Locked Status
Identifier:
locked
Unlockable: Yes
Can Use Funds: No
Can Receive Funds: Yes
Restricted Status
Identifier:
restricted
Unlockable: No
Can Use Funds: No
Can Receive Funds: No
Registering a Custom Status
To register your custom account status, use the following method:
Summary
By implementing the AccountStatus
interface and registering your custom status with TNE, you can define unique behaviors for accounts, enabling tailored restrictions or permissions for specific gameplay scenarios.
For further details, refer to existing implementations like AccountNormalStatus
, AccountLockedStatus
, and AccountRestrictedStatus
in the TNE source.
Last updated