Creating Custom Balance Format Rule
Adding Custom Currency Formatting Rules for TheNewEconomy
Overview of Format Rules
Example Default Format in YAML
Format: "<symbol><major><decimal><minor>"Creating a Custom Format Rule
1. Implement the FormatRule Interface
FormatRule Interfaceimport net.tnemc.core.account.Account;
import net.tnemc.core.account.holdings.HoldingsEntry;
import net.tnemc.core.currency.format.FormatRule;
import org.jetbrains.annotations.Nullable;
public class CustomRule implements FormatRule {
@Override
public String name() {
return "<custom>";
}
@Override
public String format(@Nullable Account account, HoldingsEntry entry, String format) {
return format.replace("<custom>", "CustomValue");
}
}2. Register the Rule
Examples of Default Rules
SymbolRule
DecimalRule
Example Custom Formatting Rule Usage
YAML Configuration
Notes
Last updated
Was this helpful?