AdvanceClans
1. 插件概述
名称: AdvanceClans (Advance ClanX)
版本: 1.0
描述: 一款面向 Minecraft 服务器的专业级、高性能氏族管理系统。专注于极致的可扩展性、最低的资源占用以及无缝的玩家体验。
2. 核心特性(性能)
性能分析
- 极端负载处理:经过测试,支持每秒 30 次击杀/死亡。
- 零 TPS 影响:所有数据库操作(点数更新、成员变更)均异步执行。主服务器线程永远不会被阻塞。
- 内存效率:对在线玩家使用智能缓存(约 10-20MB 额外开销)。不使用
Bukkit.getOfflinePlayer().getName(),从而防止常见的“null”错误和卡顿。
- 可扩展性:针对每个氏族 1,000+ 名成员 和 200+ 个活跃氏族进行了优化。
- 数据库:使用带 WAL 模式(预写式日志)的 SQLite,以实现安全、并发的高速数据访问。
3. 命令与权限
玩家命令
| 命令 |
用法 |
描述 |
权限 |
/clan |
/clan |
主 GUI 菜单。 |
clans.use |
/clan create |
/clan create <name> |
创建新氏族。 |
clans.create |
/clan join |
/clan join <name> |
申请加入氏族。 |
clans.join |
/clan accept |
/clan accept |
接受氏族邀请。 |
clans.accept |
/clan leave |
/clan leave |
离开当前氏族。 |
clans.leave |
/clan info |
/clan info [clan] |
查看氏族统计信息。 |
clans.info |
/clan top |
/clan top |
排行榜 GUI。 |
clans.top |
/clan chat |
/clan chat |
切换氏族聊天模式。 |
clans.chat |
/clan home |
/clan home |
传送至氏族出生点。 |
clans.home |
领袖/管理员命令
| 命令 |
用法 |
描述 |
权限 |
/clan invite |
/clan invite <p> |
邀请一名玩家。 |
clans.invite |
/clan kick |
/clan kick <p> |
踢出一名成员。 |
clans.kick |
/clan disband |
/clan disband |
解散氏族。 |
clans.disband |
/clan sethome |
/clan sethome |
设置出生点位置。 |
clans.sethome |
/clan cowner |
/clan cowner set <p> |
晋升为共同所有者。 |
clans.cowner |
/clan set colour |
/clan set colour <c> |
更改氏族颜色。 |
clans.set |
/forceclan delete |
/forceclan delete <c> |
管理员:删除氏族。 |
force.op |
/forceclan remove |
/forceclan remove <c> <p> |
管理员:移除成员。 |
force.op |
4. PlaceholderAPI 集成
在记分板、标签页列表或聊天中使用这些占位符:
%advanceclans_clan% - 玩家的氏族名称。
%advanceclans_role% - 玩家的职位(LEADER, COOWNER, MEMBER)。
%advanceclans_points% - 氏族的总点数。
%advanceclans_color% - 氏族的显示颜色代码。
%clans_name% → 显示玩家的氏族名称。
%clans_name_plain% → 显示去除颜色代码后的玩家氏族名称。
%clans_list_<#>_name% → 显示排行榜中该位置氏族的名称。
%clans_list_<#>_leader% → 显示排行榜中该位置氏族的领袖。
%clans_list_<#>_point% → 显示排行榜中该位置氏族的点数余额。
注意:将 <#> 替换为排行榜中的排名数字(例如,第一名氏族使用 %clans_list_1_name%)。
5. 技术规格
- 依赖项:需要 PlaceholderAPI。
- 数据库结构:
clans:存储名称、领袖名称、点数、颜色和出生点位置。
members:存储 UUID、氏族名称、职位和 last_known_name(防止出现“null”问题)。
allies:存储氏族联盟关系。
- 配置文件:
config.yml:核心限制和权限。
msg.yml:100% 可翻译的消息。
gui.yml / settingsgui.yml:完整的 GUI 自定义。
7. 数据存储内部逻辑
该插件采用多层方法来确保数据完整性和性能:
数据存储机制
- 数据库引擎:带 WAL(预写式日志) 模式的 SQLite。这允许插件在写入数据库的同时从其中读取,从而防止在较简单的插件中常见的“数据库已锁定”错误。
- 架构设计:
clans:用于元数据的主表(所有者名称、点数、颜色、出生点位置)。
members:连接玩家 UUID 与氏族名称的链接表。它包含一个 last_name 列,每次玩家加入时都会更新该列,确保即使玩家更改了名称或处于离线状态,插件也能在不查询 Mojang API 或使用 Bukkit 沉重的 getOfflinePlayer 方法的情况下显示其名称。
allies:一个简单的关系表,用于氏族之间的联盟。
功能逻辑
- 异步执行:诸如
updatePoints、createClan 和 forceDeleteClan 等功能在单独的线程上运行。这意味着如果数据库保存数据需要 100ms,服务器的 TPS 仍能保持在完美的 20.0。
- 智能缓存:启动时,插件将所有成员到氏族的关系到加载到一个
HashMap<UUID, String> 中。这使得插件能够以常数时间复杂度 (O(1)) 检查玩家是否在氏族中,而无需触及硬盘。
- 原子更新:点数更新使用 SQL 算术运算(
SET points = points + ?),而不是先读取、修改再写回。这防止了“竞争条件”,即同时发生的两次击杀可能会相互覆盖。
- 持久化策略:任何更改都会立即保存到 SQLite 文件中。如果服务器意外崩溃,不会有任何点数丢失的风险。
AdvanceClans
1. Plugin Overview
Name: AdvanceClans (Advance ClanX)
Version: 1.0
Description: A professional-grade, high-performance clan management system for Minecraft servers. Built with a focus on extreme scalability, minimal resource usage, and seamless player experience
2. Core Features (Performance)
The Performance Analysis
- Extreme Load Handling: Tested for 30 Kills/Deaths per second.
- Zero TPS Impact: All database operations (point updates, member changes) are handled Asynchronously. The main server thread is never blocked.
- Memory Efficiency: Uses smart caching for online players (~10-20MB overhead). Does NOT use
Bukkit.getOfflinePlayer().getName(), preventing the common "null" bug and lag.
- Scalability: Optimized for 1,000+ members per clan and 200+ active clans.
- Database: Uses SQLite with WAL Mode (Write-Ahead Logging) for safe, concurrent high-speed data access.
3. Commands & Permissions
Player Commands
| Command |
Usage |
Description |
Permission |
/clan |
/clan |
Main GUI Menu. |
clans.use |
/clan create |
/clan create <name> |
Create a new clan. |
clans.create |
/clan join |
/clan join <name> |
Request to join a clan. |
clans.join |
/clan accept |
/clan accept |
Accept a clan invite. |
clans.accept |
/clan leave |
/clan leave |
Leave current clan. |
clans.leave |
/clan info |
/clan info [clan] |
View clan statistics. |
clans.info |
/clan top |
/clan top |
Leaderboard GUI. |
clans.top |
/clan chat |
/clan chat |
Toggle Clan Chat mode. |
clans.chat |
/clan home |
/clan home |
Teleport to clan home. |
clans.home |
Leader/Admin Commands
| Command |
Usage |
Description |
Permission |
/clan invite |
/clan invite <p> |
Invite a player. |
clans.invite |
/clan kick |
/clan kick <p> |
Kick a member. |
clans.kick |
/clan disband |
/clan disband |
Delete the clan. |
clans.disband |
/clan sethome |
/clan sethome |
Set home location. |
clans.sethome |
/clan cowner |
/clan cowner set <p> |
Promote to Co-Owner. |
clans.cowner |
/clan set colour |
/clan set colour <c> |
Change clan color. |
clans.set |
/forceclan delete |
/forceclan delete <c> |
Admin: Delete clan. |
force.op |
/forceclan remove |
/forceclan remove <c> <p> |
Admin: Remove member. |
force.op |
4. PlaceholderAPI Integration
Use these placeholders in scoreboards, tablists, or chat:
%advanceclans_clan% - Player's clan name.
%advanceclans_role% - Player's role (LEADER, COOWNER, MEMBER).
%advanceclans_points% - Clan's total points.
%advanceclans_color% - Clan's display color code.
%clans_name% → Shows the player's clan name.
%clans_name_plain% → Shows the player's clan name stripped from color codes.
%clans_list_<#>_name% → Shows the name of the clan at that position in the leaderboard.
%clans_list_<#>_leader% → Shows the leader of the clan at that position.
%clans_list_<#>_point% → Shows the balance of the clan at that position.
Note: Replace <#> with the rank number in the leaderboard (e.g., %clans_list_1_name% for the top clan).
5. Technical Specifications
- Dependencies: Requires PlaceholderAPI.
- Database Structure:
clans: Stores name, leader name, points, color, and home location.
members: Stores UUID, clan name, role, and last_known_name (prevents "null" issues).
allies: Stores clan alliance relationships.
- Configuration Files:
config.yml: Core limits and permissions.
msg.yml: 100% translatable messages.
gui.yml / settingsgui.yml: Full GUI customization.
7. Data Saving Internal Logic
The plugin employs a multi-layered approach to data integrity and performance:
Data Storage Mechanism
- Database Engine: SQLite with WAL (Write-Ahead Logging) mode. This allows the plugin to write to the database while simultaneously reading from it, preventing the "database is locked" errors common in simpler plugins.
- Schema Design:
clans: Primary table for metadata (Owner name, Points, Color, Home Location).
members: Linking table connecting Player UUIDs to Clan names. It includes a last_name column which is updated every time a player joins, ensuring that even if a player changes their name or is offline, the plugin can display their name without querying the Mojang API or Bukkit's heavy getOfflinePlayer methods.
allies: A simple relationship table for clan-to-clan alliances.
Functional Logic
- Asynchronous Execution: Functions like
updatePoints, createClan, and forceDeleteClan run on a separate thread. This means that if the database takes 100ms to save, your server's TPS stays at a perfect 20.0.
- Smart Caching: On startup, the plugin loads all member-to-clan relationships into a
HashMap<UUID, String>. This allows the plugin to check if a player is in a clan in constant time (O(1)) without ever touching the hard drive.
- Atomic Updates: Point updates use SQL arithmetic (
SET points = points + ?) rather than reading, modifying, and writing back. This prevents "race conditions" where two kills happening at the exact same time might overwrite each other.
- Persistence Strategy: Data is saved immediately to the SQLite file upon any change. There is no risk of losing points if the server crashes unexpectedly.
评论 0
登录后参与评分
还没有评论,来抢沙发吧