CodeClaim
适用于 Minecraft 1.21.1 的服务端 Fabric 模组,允许玩家兑换代码以获取奖励。
无需客户端模组。无需数据库。
概览
CodeClaim 允许服务器管理员创建可兑换的代码,为玩家提供任意服务器命令作为奖励——给予物品、宝可梦、广播称号等。每个玩家只能兑换一次每个代码,且每个代码可以设置全局使用次数限制。所有数据均存储在简单的 JSON 文件中,无需外部数据库配置。

特性
- 任何玩家均可在没有 OP 权限的情况下使用
/claim
- 通过 UUID 强制限制每个玩家只能兑换一次每个代码
- 通过
max_uses 设置每个代码的全局使用次数上限
- 设置
max_uses: -1 以实现无限兑换
- 使用
%player% 作为占位符执行任意服务器命令作为奖励
- 所有数据自动保存到本地 JSON 文件
- 热重载配置和数据,无需重启服务器
- 仅服务端运行——玩家无需安装任何东西
依赖
- Minecraft 1.21.1
- Fabric Loader 0.15.0 或更高版本
- Fabric API 0.102.0+1.21.1
- Java 21
安装
- 从 Releases 页面下载
codeclaim-1.0.0.jar
- 下载所有必需的依赖项:Fabric Language Kotlin、Fabric API
- 将文件放入服务器的
mods/ 文件夹中,与 Fabric API 放在一起
- 启动服务器——配置文件将在
config/codeclaim.json 自动生成
- 编辑配置文件以定义你的代码和奖励
- 使用
/claimadmin reload 应用更改而无需重启
命令
| 命令 |
权限 |
描述 |
/claim <code> |
所有玩家 |
兑换代码并接收其奖励 |
/claimadmin reload |
OP 等级 2 |
从磁盘重载配置和玩家数据 |
/claimadmin info <code> |
OP 等级 2 |
查看代码的使用统计信息 |
配置
配置文件位置:config/codeclaim.json
{
"messages": {
"invalid_code": "&cCode '&4{code}&c' does not exist!",
"already_claimed": "&cYou have already redeemed '&4{code}&c'!",
"max_uses": "&cCode '&4{code}&c' has reached its usage limit!",
"success": "&aSuccessfully redeemed code '&2{code}&a'!",
"reloaded": "&aCodeClaim config reloaded!"
},
"codes": {
"WELCOME2024": {
"max_uses": -1,
"commands": [
"give %player% minecraft:bread 16"
]
},
"SHINY_EVENT": {
"max_uses": 100,
"commands": [
"givepokemonother %player% moltres form=galarian",
"title @a title {\"text\":\"A player claimed SHINY_EVENT!\",\"color\":\"gold\"}"
]
},
"GRAND_PRIZE": {
"max_uses": 1,
"commands": [
"give %player% minecraft:netherite_ingot 3",
"say %player% claimed the Grand Prize!"
]
}
}
}
字段参考
| 字段 |
描述 |
max_uses |
所有玩家的最大总兑换次数。-1 表示无限制。 |
commands |
当代码成功兑换时执行的服务器命令列表。 |
%player% |
运行时替换为兑换玩家的用户名的占位符。 |
{code} |
在消息字符串中替换为输入代码的占位符。 |
&a, &c |
支持标准 Minecraft 颜色代码,可用于所有消息字段。 |
数据存储
玩家兑换历史自动保存至:
data/codeclaim_data.json
此文件跟踪哪些玩家兑换了哪些代码,以及每个代码的总使用次数。请定期备份此文件,以便在服务器迁移时保留兑换历史。
从源码构建
要求:JDK 21,Gradle 8.8 或更高版本
git clone https://github.com/YOUR_USERNAME/codeclaim
cd codeclaim
# Linux / macOS
./gradlew build
# Windows
gradlew.bat build
编译后的 jar 包将输出到 build/libs/codeclaim-1.0.0.jar。
兼容性
| 模组 |
状态 |
| Cobblemon |
兼容 — 请使用 givepokemonother %player% |
| LuckPerms |
兼容 |
| 任何服务端命令模组 |
兼容 |
许可证
本项目遵循 MIT License 许可。详情请参阅 LICENSE。
CodeClaim
A server-side Fabric mod for Minecraft 1.21.1 that allows players to redeem codes for rewards.
No client mod required. No database required.
Overview
CodeClaim lets server administrators create redeemable codes that reward players with any server command — give items, Pokemon, broadcast titles, and more. Each player can only redeem each code once, and each code can have a global usage limit. All data is stored in simple JSON files with no external database setup required.

Features
- Any player can use
/claim without operator permissions
- Each player can only redeem each code once, enforced by UUID
- Per-code global usage limit via
max_uses
- Set
max_uses: -1 for unlimited redemptions
- Execute any server command as a reward using
%player% as a placeholder
- All data auto-saves to a local JSON file
- Hot-reload config and data without restarting the server
- Server-side only — players do not need to install anything
Requirements
- Minecraft 1.21.1
- Fabric Loader 0.15.0 or later
- Fabric API 0.102.0+1.21.1
- Java 21
Installation
- Download
codeclaim-1.0.0.jar from the Releases page
- Download all required dependencies: Fabric Language Kotlin, Fabric API
- Place the file in your server's
mods/ folder alongside Fabric API
- Start the server — the config file will be automatically generated at
config/codeclaim.json
- Edit the config to define your codes and rewards
- Use
/claimadmin reload to apply any changes without restarting
Commands
| Command |
Permission |
Description |
/claim <code> |
All players |
Redeem a code and receive its reward |
/claimadmin reload |
OP level 2 |
Reload config and player data from disk |
/claimadmin info <code> |
OP level 2 |
View usage statistics for a code |
Configuration
Config file location: config/codeclaim.json
{
"messages": {
"invalid_code": "&cCode '&4{code}&c' does not exist!",
"already_claimed": "&cYou have already redeemed '&4{code}&c'!",
"max_uses": "&cCode '&4{code}&c' has reached its usage limit!",
"success": "&aSuccessfully redeemed code '&2{code}&a'!",
"reloaded": "&aCodeClaim config reloaded!"
},
"codes": {
"WELCOME2024": {
"max_uses": -1,
"commands": [
"give %player% minecraft:bread 16"
]
},
"SHINY_EVENT": {
"max_uses": 100,
"commands": [
"givepokemonother %player% moltres form=galarian",
"title @a title {\"text\":\"A player claimed SHINY_EVENT!\",\"color\":\"gold\"}"
]
},
"GRAND_PRIZE": {
"max_uses": 1,
"commands": [
"give %player% minecraft:netherite_ingot 3",
"say %player% claimed the Grand Prize!"
]
}
}
}
Field Reference
| Field |
Description |
max_uses |
Maximum total redemptions across all players. -1 means unlimited. |
commands |
List of server commands to execute when the code is successfully redeemed. |
%player% |
Placeholder replaced with the redeeming player's username at runtime. |
{code} |
Placeholder replaced with the entered code in message strings. |
&a, &c |
Standard Minecraft color codes supported in all message fields. |
Data Storage
Player redemption history is automatically saved to:
data/codeclaim_data.json
This file tracks which players have redeemed which codes, and the total usage count per code. Back up this file regularly to preserve redemption history across server migrations.
Building from Source
Requirements: JDK 21, Gradle 8.8 or later
git clone https://github.com/YOUR_USERNAME/codeclaim
cd codeclaim
# Linux / macOS
./gradlew build
# Windows
gradlew.bat build
The compiled jar will be output to build/libs/codeclaim-1.0.0.jar.
Compatibility
| Mod |
Status |
| Cobblemon |
Compatible — use givepokemonother %player% |
| LuckPerms |
Compatible |
| Any server-side command mod |
Compatible |
License
This project is licensed under the MIT License. See LICENSE for details.
评论 0
登录后参与评分
还没有评论,来抢沙发吧