# 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:

```java
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

```java
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

```java
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

```java
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:

```java
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.
