The Economy API for Hytale Servers
Ledger is a modern, async-first economy API for Hytale servers. It provides a standardized interface for economy operations, similar to what Vault does for Minecraft.
- Async by Default - All I/O operations use
CompletableFutureto never block the server - Multi-Currency Support - Primary currency + unlimited additional currencies
- Flexible Storage - JSON (development) or SQLite (production)
- Rich Event System - Pre/Post transaction events with cancel/modify support
- Transaction Logging - Full audit trail of all economy operations
- Payment Notifications - Players receive messages when they get paid
- Easy Integration - Simple API for other mods to integrate
- Download
Ledger-1.0.0.jarfrom Releases - Place in your Hytale server's
Modsfolder - Restart the server
- Configuration files will be generated in
mods/KarmaByte_Ledger/
| Command | Permission | Description |
|---|---|---|
/balance [player] |
None / ledger.balance.others |
Check your or another player's balance |
/pay <player> <amount> |
None | Send money to another player |
/baltop [page] |
None | View richest players |
/eco give <player> <amount> |
ledger.admin |
Give money to a player |
/eco take <player> <amount> |
ledger.admin |
Take money from a player |
/eco set <player> <amount> |
ledger.admin |
Set a player's balance |
/eco reset <player> |
ledger.admin |
Reset balance to default |
/ledger reload |
ledger.admin.reload |
Reload configuration |
/ledger info |
ledger.admin |
View plugin information |
/ledger version |
ledger.admin |
View plugin version |
{
"storageType": "sqlite",
"currencyId": "coins",
"currencyDisplayName": "Coins",
"currencySingular": "coin",
"currencyPlural": "coins",
"currencySymbol": "$",
"currencyDecimals": 2,
"startingBalance": 100.0,
"minBalance": 0.0,
"maxBalance": 1000000000.0,
"minPayAmount": 0.01,
"maxPayAmount": 1000000.0,
"payCooldownSeconds": 0,
"transactionLogging": true,
"debug": false
}| Storage | Best For | File |
|---|---|---|
json |
Development, testing | data/*.json |
sqlite |
Production servers | ledger.db |
Add the Ledger API JAR to your project:
// build.gradle.kts
dependencies {
compileOnly(files("libs/ledger-api-1.0.0.jar"))
}import dev.karmabyte.ledger.api.Ledger;
import dev.karmabyte.ledger.api.LedgerProvider;
import dev.karmabyte.ledger.api.economy.EconomyService;
// Get the economy provider
LedgerProvider provider = Ledger.getProvider();
EconomyService economy = provider.getEconomyService();
// Check balance
economy.getBalance(playerUuid).thenAccept(balance -> {
System.out.println("Balance: " + balance);
});
// Deposit money
economy.deposit(playerUuid, 100.0).thenAccept(result -> {
if (result.isSuccess()) {
System.out.println("Deposited " + result.getAmountFormatted());
}
});
// Withdraw money
economy.withdraw(playerUuid, 50.0).thenAccept(result -> {
if (result.isSuccess()) {
giveItemToPlayer(player, item);
} else if (result.getStatus() == TransactionResult.Status.INSUFFICIENT_FUNDS) {
player.sendMessage("Not enough money!");
}
});
// Transfer between players
economy.transfer(fromUuid, toUuid, 25.0).thenAccept(result -> {
if (result.isSuccess()) {
System.out.println("Transfer complete!");
}
});Hook into the economy system to add taxes, logging, or custom behavior:
// In your plugin's setup method
getEventRegistry().register(PreTransactionEvent.class, event -> {
// Cancel large transactions
if (event.getAmount() > 10000) {
event.cancel("Amount exceeds server limit");
return;
}
// Apply 5% tax on deposits
if (event.getType() == TransactionType.DEPOSIT) {
double taxed = event.getAmount() * 0.95;
event.setAmount(taxed);
}
});
getEventRegistry().register(PostTransactionEvent.class, event -> {
if (event.isSuccess() && event.getType() == TransactionType.TRANSFER) {
// Log successful transfers
getLogger().atInfo().log("%s sent %s to someone",
event.getAccount().getName(),
event.getResult().getAmountFormatted());
}
});
getEventRegistry().register(BalanceChangeEvent.class, event -> {
// Update scoreboards when balance changes
updatePlayerScoreboard(event.getAccount().getOwner(), event.getNewBalance());
});import dev.karmabyte.ledger.api.economy.Currency;
import dev.karmabyte.ledger.api.economy.CurrencyBuilder;
// Create a custom currency
Currency gems = CurrencyBuilder.create("gems")
.displayName("Gems")
.singular("gem")
.plural("gems")
.symbol("G")
.decimals(0)
.defaultBalance(0.0)
.minBalance(0.0)
.maxBalance(100000.0)
.build();
// Register it
economy.registerCurrency(gems);
// Use the custom currency
economy.deposit(playerUuid, gems, 50.0);
economy.getBalance(playerUuid, gems).thenAccept(balance -> {
player.sendMessage("You have " + gems.format(balance));
});| Class | Description |
|---|---|
Ledger |
Static entry point - Ledger.getProvider() |
LedgerProvider |
Main provider with economy service access |
EconomyService |
All economy operations (balance, deposit, withdraw, transfer) |
Account |
Player account with multi-currency balances |
Currency |
Currency definition with formatting |
TransactionResult |
Operation result with status, amounts, and messages |
| Event | Cancellable | Description |
|---|---|---|
PreTransactionEvent |
Yes | Before any transaction - can cancel or modify amount |
PostTransactionEvent |
No | After transaction completes with result |
BalanceChangeEvent |
No | When any balance changes |
git clone https://github.com/KarmaByte-SL/Ledger.git
cd Ledger
# Place hytale-server.jar in libs/ folder
./gradlew buildOutput JARs:
api/build/libs/api-1.0.0-SNAPSHOT.jar- API for other modscore/build/libs/core-1.0.0-SNAPSHOT.jar- Full plugin
Contributions are welcome!
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see LICENSE for details.
KarmaByte - GitHub
Made with love for the Hytale community