> For the complete documentation index, see [llms.txt](https://tne.gitbook.io/tne-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tne.gitbook.io/tne-docs/faq-howto/how-to-limit-access-to-currencies.md).

# HOW TO: Limit Access to Currencies

The **limitCurrency** feature in TheNewEconomy allows server administrators to restrict specific actions for players based on permissions tied to individual currencies. This is useful for providing fine-grained control over who can interact with particular currencies and in what ways.

### Configuration

To enable this feature, set `Core.LimitCurrency` to `true` in your `config.yml`:

```yaml
Core:
  LimitCurrency: true
```

Once enabled, permissions checks will be applied for various currency-related actions.

### Permissions

Each action requires a permission in the format:\
`tne.money.[action].[currency]`

Replace `[action]` with the action being restricted and `[currency]` with the currency identifier. For example:

* `tne.money.balance.usd` – Allows checking the balance for the USD currency.
* `tne.money.deposit.euro` – Allows depositing funds in the Euro currency.

#### Supported Actions

Here is a list of actions that can be restricted using `limitCurrency`:

<table><thead><tr><th width="150">Action</th><th width="249">Description</th><th>Example Permission</th></tr></thead><tbody><tr><td>balance</td><td>Checking a balance</td><td><code>tne.money.balance.usd</code></td></tr><tr><td>deposit</td><td>Depositing funds</td><td><code>tne.money.deposit.euro</code></td></tr><tr><td>withdraw</td><td>Withdrawing funds</td><td><code>tne.money.withdraw.usd</code></td></tr><tr><td>convert</td><td>Converting between currencies</td><td><code>tne.money.convert.to.usd</code></td></tr><tr><td>pay</td><td>Paying other players</td><td><code>tne.money.pay.usd</code></td></tr><tr><td>request</td><td>Requesting funds from players</td><td><code>tne.money.request.usd</code></td></tr><tr><td>top</td><td>Viewing the leaderboard for balances</td><td><code>tne.money.top.usd</code></td></tr><tr><td>set</td><td>Setting player balances</td><td><code>tne.money.set.usd</code></td></tr><tr><td>take</td><td>Taking funds from players</td><td><code>tne.money.take.usd</code></td></tr><tr><td>note</td><td>Creating currency notes</td><td><code>tne.money.note.usd</code></td></tr></tbody></table>

### How It Works

When `limitCurrency` is enabled, TheNewEconomy checks the permissions before performing any action. If a player lacks the required permission, they will receive a customizable message indicating the action is blocked.

Example code for permission checks from `MoneyCommand.java`:

```java
if(EconomyManager.limitCurrency() && player.isPresent()) {
  if(!player.get().hasPermission("tne.money.balance." + currency.getIdentifier())) {
    final MessageData data = new MessageData("Messages.Account.BlockedAction");
    data.addReplacement("$action", "balance check");
    data.addReplacement("$currency", currency.getDisplay());
    sender.message(data);
    return;
  }
}
```

#### Customizing Messages

Blocked action messages can be customized in `messages.yml` under `Messages.Account.BlockedAction`. Example:

```yaml
Messages:
  Account:
    BlockedAction: "<red>You don't have permission to perform the $action action with the $currency currency."
```

### Summary

The `limitCurrency` feature provides server administrators with powerful tools to control access to specific currencies and actions. This ensures that currency-related functionality aligns with your server's rules and permissions system.
