Creating Custom Balance Handlers
Creating a Custom HoldingsHandler for TheNewEconomy
What is a HoldingsHandler?
Steps to Create a Custom HoldingsHandler
1. Implement the HoldingsHandler Interface
import net.tnemc.core.account.Account;
import net.tnemc.core.account.holdings.HoldingsEntry;
import net.tnemc.core.account.holdings.HoldingsHandler;
import net.tnemc.core.currency.Currency;
import net.tnemc.core.currency.CurrencyType;
import net.tnemc.core.utils.Identifier;
import java.math.BigDecimal;
public class CustomHandler implements HoldingsHandler {
@Override
public Identifier identifier() {
return new Identifier("custom_handler"); // Unique identifier for this handler
}
@Override
public boolean supports(Currency currency, CurrencyType type) {
// Define the logic for supported currencies or types
return true;
}
@Override
public boolean setHoldings(Account account, String region, Currency currency, CurrencyType type, BigDecimal amount) {
// Define how holdings are stored for the account
return true;
}
@Override
public HoldingsEntry getHoldings(Account account, String region, Currency currency, CurrencyType type) {
// Define how holdings are retrieved for the account
return new HoldingsEntry(region, currency.getUid(), BigDecimal.ZERO, identifier());
}
}2. Register the Handler with TNE
Example Implementations
EnderChestHandler
ExperienceHandler
Key Points
Notes
Last updated
Was this helpful?