Creating Custom Transaction Type
Creating a Custom Transaction Type for TheNewEconomy
Transaction types in TheNewEconomy (TNE) define the behavior of different financial operations, such as withdrawals, deposits, or currency conversions. This guide explains how to implement and register a custom transaction type.
Overview
What is a Transaction Type?
A Transaction Type represents a specific operation within TNE's economy system. It specifies:
Identifier: A unique name for the transaction type.
Taxation Rules: How taxes are applied to the sender and recipient.
Registration
To use a custom transaction type, register it with TNE's transaction manager:
Steps to Create a Custom Transaction Type
Step 1: Implement the TransactionType
Interface
TransactionType
InterfaceCreate a class that implements the TransactionType
interface. Below is an example of a custom type called CustomFeeType
.
Step 2: Register the Custom Transaction Type
To register your transaction type, use the following code:
Examples of Default Transaction Types
DepositType
Handles deposits into accounts:
WithdrawType
Handles withdrawals from accounts:
PayType
Handles payments between players:
Key Methods in TransactionType
TransactionType
identifier()
Returns the unique identifier for the transaction type.
toTax()
Specifies the tax applied to the recipient of the transaction.
fromTax()
Specifies the tax applied to the sender of the transaction.
Notes
Unique Identifier: Ensure your transaction type has a unique identifier using the
identifier()
method.Tax Customization: Use
toTax()
andfromTax()
to define tax rules specific to your transaction type.Registration: Always register your custom type with
TNECore.eco().transaction().addType()
.
By implementing and registering custom transaction types, you can introduce tailored financial operations to enhance your server's economy system.
Last updated