Creating Custom TaxType
Creating a Custom Tax Type for TheNewEconomy
In TheNewEconomy, tax types define how taxation is calculated and applied during transactions. This guide explains how to implement and register a custom tax type.
Overview
What is a Tax Type?
A Tax Type is a mechanism that determines how taxes are calculated based on transaction amounts. Examples include flat taxes or percentage-based taxes.
Registration
To use a custom tax type, register it during the plugin’s initialization:
Steps to Create a Custom Tax Type
Step 1: Implement the TaxType
Interface
TaxType
InterfaceCreate a class that implements the TaxType
interface. Below is an example of a custom tax type called CustomFlatTaxType
:
Step 2: Register the Custom Tax Type
To register the tax type, use the following code:
Example: Default Tax Types in TNE
FlatType
Applies a fixed tax amount regardless of the transaction size:
PercentileType
Applies a tax as a percentage of the transaction amount:
Key Methods in TaxType
TaxType
name()
Returns the unique identifier for the tax type.
asString()
Converts the tax value to a display-friendly string.
handleTaxation()
Implements the logic to calculate the tax based on the transaction amount and tax value.
Notes
Dynamic Taxation: Customize
handleTaxation()
to apply taxes dynamically based on complex rules.Unique Identifier: Ensure
name()
returns a unique identifier for the tax type.Testing: Test your tax type to ensure it integrates properly with TNE's transaction system.
By implementing and registering custom tax types, you can introduce unique taxation systems tailored to your server's economic rules.
Last updated