Creating Custom Currency Loader & Saver
Creating a Custom Currency Loader and Saver for TheNewEconomy
TheNewEconomy provides flexibility for managing currencies by allowing developers to implement custom currency loaders and savers. These components enable advanced control over how currencies are read from or written to storage.
Overview
Currency Loader
A Currency Loader is responsible for loading currencies and their denominations from a specified storage or configuration source.
Currency Saver
A Currency Saver handles saving currencies and their denominations to storage or configuration files.
Registration
To use your custom loader or saver, register it during the plugin's initialization:
Creating a Custom Currency Loader
Step 1: Implement the CurrencyLoader
Interface
CurrencyLoader
InterfaceCreate a class that implements the CurrencyLoader
interface. Below is an example:
Creating a Custom Currency Saver
Step 1: Implement the CurrencySaver
Interface
CurrencySaver
InterfaceCreate a class that implements the CurrencySaver
interface. Below is an example:
Example: Registering Custom Loader and Saver
To activate your custom loader and saver, register them as follows:
Notes
Error Handling: Ensure your loader and saver handle errors gracefully to avoid corrupting currency data.
File Structure: Maintain a clear file structure for storing and retrieving currencies and denominations.
Testing: Thoroughly test your loader and saver to ensure compatibility with the TNE ecosystem.
By implementing and registering custom loaders and savers, you can extend TheNewEconomy's capabilities to integrate with unique storage solutions or advanced configurations.
Last updated