Skip to content

two-tech-dev/UniversalEconomy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

UniversalEconomy

UniversalEconomy is an economy plugin made for Endstone focused on performance, simplicity, and multi-database support.

Table of Contents

Commands

Name Description Usage Permission
balance Show your and others balance balance [player: string] economy.balance
pay Pay others with your balance pay <player: string> <amount: float> economy.pay
rich View the top balances rich [page: int] economy.rich
addbalance Add funds to others balance addbalance <player: string> <amount: float> economy.admin
removebalance Remove funds from others balance removebalance <player: string> <amount: float> economy.admin
setbalance Set others balance setbalance <player: string> <amount: float> economy.admin

Features

  • MySQL Database
  • SQLite Database
  • Service API for other plugins
  • Easy to use
  • Lightweight
  • Fast and efficient
  • TTL-based cache system
  • Multi-language support (English, Vietnamese, Russian, Korean)
  • Customizable currency formatting
  • Transaction events (cancellable)

Examples

Retrieving a Player's Balance

You can retrieve a player's balance using the get method. This reads from cache and returns instantly.

#include <economy/api.h>

auto eco = server.getServiceManager().load<economy::EconomyAPI>("Economy");
if (!eco) {
    // Economy service not available
    return;
}

double balance = eco->get("player_xuid");

Retrieving Top Balances

You can retrieve the top balances using the bulk method.

auto top = eco->bulk(10); // top 10 players

for (auto &entry : top) {
    logger.info("{}: {}", entry.player, entry.balance);
}

Adding Funds to a Player's Balance

You can add funds to a player's balance using the add method.

auto future = eco->add("player_xuid", 500.0);

bool success = future.get();
if (!success) {
    // Failed (e.g., event was cancelled)
}

Subtracting Funds from a Player's Balance

You can subtract funds from a player's balance using the subtract method.

auto future = eco->subtract("player_xuid", 100.0);

bool success = future.get();
if (!success) {
    // Failed (e.g., insufficient funds, or event was cancelled)
}

Transferring Funds Between Players

You can transfer funds from one player to another using the transfer method.

auto future = eco->transfer("source_xuid", "target_xuid", 250.0);

bool success = future.get();
if (!success) {
    // Failed (e.g., insufficient funds, same player, or event was cancelled)
}

Configuration

The default configuration is generated at plugins/universal_economy/config.yml:

locale: "en-US"

database:
  type: "sqlite"
  mysql:
    host: "localhost"
    port: 3306
    database: "economy"
    username: "root"
    password: ""

currency:
  name: "United States Dollar"
  code: "USD"
  symbol: "$"
  formatter: "compact"  # compact or commadot
  default:
    amount: 0
    decimals: "00"
  decimals: false

cache:
  invalidation: 300      # Cache TTL in seconds, 0 to disable
  rich-rows: 100         # Max rows for /rich command, 0 for all
  balance-command: true   # Cache /balance reads

Language Support

Language files are generated at plugins/universal_economy/language/. Supported locales:

  • en-US (English) — default
  • vi-VN (Vietnamese)
  • ru-RU (Russian)
  • ko-KR (Korean)

To add a new language, create a new .yml file in the language/ folder following the same key structure as en-US.yml, then set locale in config.yml.

License

This project is released under the MIT License. For more information, please refer to the LICENSE file.

About

UniversalEconomy is an economy plugin made for Endstone focused on performance, simplicity, and multi-database support.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors