Plugin API
Storage and Economy
Config files, per-player data, an economy, leaderboards and daily streaks.
Updated Dec 5, 2026
Plugins store data as plain files in their private data folder. These helpers wrap the common cases. Every module on this page needs the fs.read.data and fs.write.data permissions, except the pure in-memory ones (Leaderboard, streak).
| Module | Similar to | What it gives you |
|---|---|---|
config::PluginConfig | getConfig() | config.toml in the data folder with defaults, dotted paths, typed getters, set, save, reload |
playerdata::PlayerData | Per-player data files | PlayerData::load(&ctx): get_i64, get_str, get_bool, the matching setters, add_i64, remove, all_i64(key). Stored in playerdata.toml |
economy::Economy | Vault Economy | File-backed balances in economy.toml: balance, has, set, deposit, withdraw, transfer, top, format. Stored as whole cents |
leaderboard::Leaderboard | Top lists | set, add, get, top, rank_of, render |
streak | Daily rewards | claim(last_day, today, streak), day_index(unix_secs), reward(base, step, cap, streak) |
shop::PriceList | Shop price lists | PriceList::from_config, quote_buy, quote_sell |
Economy
use rocketmc_plugin_api::prelude::*;
fn on_load(&self, ctx: Context) -> Result<()> {
let eco = Economy::load(&ctx).map_err(|e| e.to_string())?;
// accounts are keyed by the player's UUID hex
// let id = account_of(&player);
// eco.deposit(&id, 50.0)?;
// eco.withdraw(&id, 10.0)?; // Err(EconomyError) when funds are short
// eco.transfer(&from, &to, 5.0)?;
// for (account, balance) in eco.top(10) { /* ... */ }
Ok(())
}
The economy belongs to your plugin. Other plugins cannot read it, because each plugin has its own data folder.
Player data
let data = PlayerData::load(&ctx).map_err(|e| e.to_string())?;
let id = account_of(&player);
let joins = data.add_i64(&id, "joins", 1).map_err(|e| e.to_string())?;
Leaderboards and streaks
let mut board = Leaderboard::new();
board.add("Steve", 10);
board.add("Alex", 25);
for line in board.render("&6Top players", 5) {
player.send_message(&line);
}
ratelimit::RateLimiter, confirm::Confirmations, toggle::ToggleSet and tprequest::TeleportRequests have a const fn new(), so they can live in a static.