KartaEmeraldCurrency
KartaEmeraldCurrency 是一款面向 PaperMC 服务器的现代高性能经济插件,它以原版绿宝石物品作为核心货币。该插件具备虚拟银行系统、交互式图形用户界面(GUI)以及强大的开发者 API,使其成为适用于任何服务器的多功能且稳定的选择。
为确保高效与安全,所有数据库操作均异步执行,从而防止服务器卡顿。
兼容性: PaperMC 1.21 – 1.21.8 (Java 21+)
功能特性
- 基于绿宝石的经济系统: 使用实体绿宝石进行存款和取款。
- 虚拟银行: 将您的绿宝石安全地存储在虚拟银行账户中,免受背包丢失风险。
- 交互式 GUI: 提供现代化且易于使用的图形界面,用于处理所有常见操作,可通过
/emerald 命令访问。
- 主菜单: 显示您账户余额的摘要。
- 银行 GUI: 专门用于存取绿宝石的界面。您可以一键从背包中存入所有绿宝石,或者通过在聊天中输入数值来存取特定金额。
- Vault 集成: 可作为任何兼容 Vault 插件的主要经济提供者。
- PlaceholderAPI 支持: 提供完整的占位符集,以便在记分板、聊天等地方显示经济数据。
- 开发者 API: 提供简洁的异步 API,供其他插件与经济系统进行交互。
- 异步与高性能: 所有数据库 I/O 均为异步操作,确保您的服务器保持无卡顿状态。
- 高度可配置: 几乎所有方面,从手续费到提示信息,均可自定义。
安装方法
- 从 Releases 页面下载最新版本。
- 将
KartaEmeraldCurrency-x.x.x.jar 文件放入服务器的 /plugins 目录中。
- 重启服务器。默认配置文件将在
/plugins/KartaEmeraldCurrency/ 目录下生成。
命令与权限
用户命令 (/emerald 或 /kec)
与经济系统交互的主要方式是通过主 GUI (/emerald)。虽然可能存在一些直接命令,但 GUI 提供了对所有功能的访问权限,包括银行、转账和排行榜。
| 命令 |
权限 |
描述 |
/emerald |
kec.gui |
打开主要的交互式 GUI。 |
/emerald balance |
kec.balance |
显示您当前的银行余额、钱包余额及总余额。 |
/emerald pay <player> <amount> |
kec.pay |
从您的银行账户向其他玩家付款。 |
/emerald deposit <amount> |
kec.deposit |
将实体绿宝石存入您的银行。 |
/emerald withdraw <amount> |
kec.withdraw |
从您的银行提取绿宝石至背包。 |
/emerald top |
kec.top |
显示最富有玩家的排行榜。 |
/emerald help |
kec.help |
显示帮助信息。 |
管理员命令 (/emeraldadmin 或 /kecadmin)
所有管理员命令都需要基础权限 kec.admin 或细分权限。
| 命令 |
权限 |
描述 |
/kecadmin set <player> <amount> |
kec.admin.set |
设置玩家的银行余额。 |
/kecadmin add <player> <amount> |
kec.admin.add |
增加玩家的银行余额。 |
/kecadmin remove <player> <amount> |
kec.admin.remove |
减少玩家的银行余额。 |
/kecadmin give <player> <amount> |
kec.admin.give |
给予玩家实体绿宝石。 |
/kecadmin take <player> <amount> |
kec.admin.take |
从玩家处扣除实体绿宝石。 |
/kecadmin reload |
kec.admin.reload |
重新加载配置文件。 |
/kecadmin migrate <source_type> |
kec.admin.migrate |
将数据从一个存储类型迁移到另一个存储类型(例如从 SQLITE 迁移到 MYSQL)。 |
占位符
需要 PlaceholderAPI。
%kartaemerald_balance% - 玩家的总银行余额。
%kartaemerald_balance_formatted% - 格式化后的玩家银行余额,带有后缀(例如 1.2k)。
%kartaemerald_balance_comma% - 带逗号分隔符的玩家银行余额(例如 1,234,567)。
%kartaemerald_bank% - %kartaemerald_balance% 的别名。
%kartaemerald_wallet% - 玩家背包中的实体绿宝石数量。
%kartaemerald_top_<1-10>_name% - (尚未实现) 排行榜上第 N 名玩家的名称。
%kartaemerald_top_<1-10>_amount% - (尚未实现) 排行榜上第 N 名玩家的余额。
关于自定义占位符的说明: 在配置文件中(gui.yml、messages.yml),您可以使用上下文特定的占位符。这些占位符采用 <placeholder_name> 格式,与 MiniMessage 库兼容。例如,在排行榜 GUI 中,您可以使用 <rank>、<player_name> 和 <balance>。
开发者 API
KartaEmeraldCurrency 为开发者提供了一个简洁易用的 API。所有涉及数据的方法都是异步的,并返回一个 CompletableFuture。
访问 API
首先,从 Bukkit 的 ServicesManager 获取服务。
import com.minekarta.kec.api.KartaEmeraldService;
import org.bukkit.Bukkit;
import org.bukkit.plugin.RegisteredServiceProvider;
public class MyPlugin {
private KartaEmeraldService economyService;
public void onEnable() {
RegisteredServiceProvider<KartaEmeraldService> rsp = Bukkit.getServicesManager().getRegistration(KartaEmeraldService.class);
if (rsp != null) {
this.economyService = rsp.getProvider();
}
}
}
使用示例:向玩家付款
import com.minekarta.kec.api.TransferReason;
```java
public void rewardPlayer(Player player, long amount) {
if (economyService != null) {
// 不支持通过为 'from' 参数使用 null UUID 来从“无”(服务器)转账。
// 相反,请使用 addBankBalance 方法处理服务器到玩家的交易。
economyService.addBankBalance(player.getUniqueId(), amount).thenAccept(success -> {
if (success) {
player.sendMessage("You have been rewarded " + amount + " emeralds!");
}
});
}
}
KartaEmeraldCurrency
KartaEmeraldCurrency is a modern, high-performance economy plugin for PaperMC servers that uses the vanilla Emerald item as its core currency. It features a virtual bank system, interactive GUIs, and a powerful developer API, making it a versatile and stable choice for any server.
Built to be efficient and safe, all database operations are handled asynchronously to prevent server lag.
Compatibility: PaperMC 1.21 – 1.21.8 (Java 21+)
Features
- Emerald-Based Economy: Uses physical Emeralds for deposits and withdrawals.
- Virtual Bank: Securely store your emeralds in a virtual bank account, safe from inventory loss.
- Interactive GUI: A modern and easy-to-use GUI for all common actions, accessible via
/emerald.
- Main Menu: Shows a summary of your account balance.
- Bank GUI: A dedicated interface for depositing and withdrawing emeralds. You can deposit all emeralds from your inventory with one click, or deposit/withdraw a custom amount by entering the value in chat.
- Vault Integration: Can act as the primary economy provider for any Vault-compatible plugin.
- PlaceholderAPI Support: A full set of placeholders to display economic data on scoreboards, chat, etc.
- Developer API: A clean, asynchronous API for other plugins to interact with the economy.
- Async & Performant: All database I/O is asynchronous to ensure your server remains lag-free.
- Configurable: Almost every aspect, from fees to messages, can be customized.
Installation
- Download the latest release from the Releases page.
- Place the
KartaEmeraldCurrency-x.x.x.jar file into your server's /plugins directory.
- Restart your server. The default configuration files will be generated in
/plugins/KartaEmeraldCurrency/.
Commands & Permissions
User Commands (/emerald or /kec)
The primary way to interact with the economy is through the main GUI (/emerald). While some direct commands may exist, the GUI provides access to all features, including the Bank, Transfers, and Leaderboards.
| Command |
Permission |
Description |
/emerald |
kec.gui |
Opens the main interactive GUI. |
/emerald balance |
kec.balance |
Shows your current bank, wallet, and total balance. |
/emerald pay <player> <amount> |
kec.pay |
Pays another player from your bank account. |
/emerald deposit <amount> |
kec.deposit |
Deposits physical emeralds into your bank. |
/emerald withdraw <amount> |
kec.withdraw |
Withdraws emeralds from your bank to your inventory. |
/emerald top |
kec.top |
Shows the leaderboard of the richest players. |
/emerald help |
kec.help |
Displays a help message. |
Admin Commands (/emeraldadmin or /kecadmin)
All admin commands require the base permission kec.admin or granular permissions.
| Command |
Permission |
Description |
/kecadmin set <player> <amount> |
kec.admin.set |
Sets a player's bank balance. |
/kecadmin add <player> <amount> |
kec.admin.add |
Adds to a player's bank balance. |
/kecadmin remove <player> <amount> |
kec.admin.remove |
Removes from a player's bank balance. |
/kecadmin give <player> <amount> |
kec.admin.give |
Gives a player physical emeralds. |
/kecadmin take <player> <amount> |
kec.admin.take |
Takes physical emeralds from a player. |
/kecadmin reload |
kec.admin.reload |
Reloads the configuration files. |
/kecadmin migrate <source_type> |
kec.admin.migrate |
Migrates data from one storage type to another (e.g., SQLITE to MYSQL). |
Placeholders
Requires PlaceholderAPI.
%kartaemerald_balance% - Player's total bank balance.
%kartaemerald_balance_formatted% - Player's bank balance, formatted with suffixes (e.g., 1.2k).
%kartaemerald_balance_comma% - Player's bank balance, formatted with commas (e.g., 1,234,567).
%kartaemerald_bank% - An alias for %kartaemerald_balance%.
%kartaemerald_wallet% - Player's physical emerald count in their inventory.
%kartaemerald_top_<1-10>_name% - (Not yet implemented) Name of the Nth player on the leaderboard.
%kartaemerald_top_<1-10>_amount% - (Not yet implemented) Balance of the Nth player on a leaderboard.
Note on custom placeholders: In configuration files (gui.yml, messages.yml), you can use context-specific placeholders. These use the <placeholder_name> format, which is compatible with the MiniMessage library. For example, in the leaderboard GUI, you can use <rank>, <player_name>, and <balance>.
Developer API
KartaEmeraldCurrency provides a clean, easy-to-use API for developers. All data-related methods are asynchronous and return a CompletableFuture.
Accessing the API
First, get the service from Bukkit's ServicesManager.
import com.minekarta.kec.api.KartaEmeraldService;
import org.bukkit.Bukkit;
import org.bukkit.plugin.RegisteredServiceProvider;
public class MyPlugin {
private KartaEmeraldService economyService;
public void onEnable() {
RegisteredServiceProvider<KartaEmeraldService> rsp = Bukkit.getServicesManager().getRegistration(KartaEmeraldService.class);
if (rsp != null) {
this.economyService = rsp.getProvider();
}
}
}
Example Usage: Paying a Player
import com.minekarta.kec.api.TransferReason;
public void rewardPlayer(Player player, long amount) {
if (economyService != null) {
// Transfer from no one (server) by using a null UUID for the 'from' parameter is not supported.
// Instead, use the addBankBalance method for server-to-player transactions.
economyService.addBankBalance(player.getUniqueId(), amount).thenAccept(success -> {
if (success) {
player.sendMessage("You have been rewarded " + amount + " emeralds!");
}
});
}
}
评论 0
登录后参与评分
还没有评论,来抢沙发吧