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
  • Configuration
  • Permissions
  • How It Works
  • Summary
  1. FAQ HOWTO

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:

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:

Action
Description
Example Permission

balance

Checking a balance

tne.money.balance.usd

deposit

Depositing funds

tne.money.deposit.euro

withdraw

Withdrawing funds

tne.money.withdraw.usd

convert

Converting between currencies

tne.money.convert.to.usd

pay

Paying other players

tne.money.pay.usd

request

Requesting funds from players

tne.money.request.usd

top

Viewing the leaderboard for balances

tne.money.top.usd

set

Setting player balances

tne.money.set.usd

take

Taking funds from players

tne.money.take.usd

note

Creating currency notes

tne.money.note.usd

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:

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:

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.

PreviousPlaceholderAPI PlaceholdersNextHOWTO: Contribute Translation

Last updated 5 months ago