TNE Docs
  • Getting Started
    • Welcome
    • Currencies Key Concepts
    • Creating a Currency
    • Breakdown of Main Currency Configuration File
    • Breakdown of Denomination Configuration File
    • Commands & Permissions
    • PlaceholderAPI Placeholders
  • FAQ HOWTO
    • HOW TO: Limit Access to Currencies
    • HOWTO: Contribute Translation
    • HOWTO: Share Balances Across Servers
  • Developers
    • Welcome Developers
    • Contributing
    • API Usage
    • Callbacks
    • Platform Implementations
    • Creating Custom Account Type
    • Creating Custom Balance Handlers
    • Creating Custom Account Statuses
    • Creating Custom Balance Format Rule
    • Creating Custom Currency Loader & Saver
    • Creating Custom Currency Type
    • Creating Custom Transaction Checks
    • Creating Custom TaxType
    • Creating Custom Transaction Type
Powered by GitBook
On this page
  • Creating Custom Account Statuses for TheNewEconomy
  • Overview of AccountStatus
  • Example: Implementing a Custom Status
  • Example: Default Account Statuses in TNE
  • Registering a Custom Status
  • Summary
  1. Developers

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:

  1. identifier(): Returns a unique identifier for the status.

  2. unlockable(): Indicates if the status can be unlocked using the account's PIN.

  3. use(): Specifies if the account can use funds.

  4. 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:

import net.tnemc.core.account.AccountStatus;
import net.tnemc.plugincore.core.io.maps.MapKey;
import org.jetbrains.annotations.NotNull;

public class FrozenStatus implements AccountStatus {

  @Override
  @MapKey
  public @NotNull String identifier() {
    return "frozen";
  }

  @Override
  public boolean unlockable() {
    return false;
  }

  @Override
  public boolean use() {
    return false;
  }

  @Override
  public boolean receive() {
    return false;
  }
}

Example: Default Account Statuses in TNE

Normal Status

  • Identifier: normal

  • Unlockable: No

  • Can Use Funds: Yes

  • Can Receive Funds: Yes

public class AccountNormalStatus implements AccountStatus {
  @Override
  public @NotNull String identifier() { return "normal"; }
  @Override
  public boolean unlockable() { return false; }
  @Override
  public boolean use() { return true; }
  @Override
  public boolean receive() { return true; }
}

Locked Status

  • Identifier: locked

  • Unlockable: Yes

  • Can Use Funds: No

  • Can Receive Funds: Yes

public class AccountLockedStatus implements AccountStatus {
  @Override
  public @NotNull String identifier() { return "locked"; }
  @Override
  public boolean unlockable() { return true; }
  @Override
  public boolean use() { return false; }
  @Override
  public boolean receive() { return true; }
}

Restricted Status

  • Identifier: restricted

  • Unlockable: No

  • Can Use Funds: No

  • Can Receive Funds: No

public class AccountRestrictedStatus implements AccountStatus {
  @Override
  public @NotNull String identifier() { return "restricted"; }
  @Override
  public boolean unlockable() { return false; }
  @Override
  public boolean use() { return false; }
  @Override
  public boolean receive() { return false; }
}

Registering a Custom Status

To register your custom account status, use the following method:

TNECore.eco().account().addAccountStatus(new FrozenStatus());

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.

PreviousCreating Custom Balance HandlersNextCreating Custom Balance Format Rule

Last updated 5 months ago