主配置 config.yml
plugins/GTCDK/config.yml 控制 GTCDK 的存储、兑换输入方式、防爆破、默认 GUI 和提示消息。
CDK 模板、兑换配置、自定义 GUI 和自定义命令分别放在对应文件夹中。
常用目录:
text
plugins/GTCDK/
config.yml
templates/
exchanges/
guis/
commands/修改后执行:
text
/gtcdk reload涉及存储后端切换时,建议重启服务器。
storage 存储
yaml
storage:
backend: "auto"
namespace: "gtcdk"| 字段 | 作用 |
|---|---|
backend | 存储后端 |
namespace | 数据命名空间 |
backend 可选:
text
auto 使用 GTCore 当前可用存储
local 本地存储
mysql MySQL
redis Redis单服默认:
yaml
storage:
backend: "auto"多服共享 CDK 使用记录时,建议在 GTCore 配好 MySQL 或 Redis,然后 GTCDK 使用:
yaml
storage:
backend: "auto"需要强制 MySQL:
yaml
storage:
backend: "mysql"
namespace: "gtcdk"redeem 兑换输入
yaml
redeem:
default-input: "auto"
code-case-sensitive: false
trim-spaces: true
cooldown-ms: 1200| 字段 | 作用 |
|---|---|
default-input | 默认输入方式 |
code-case-sensitive | CDK 是否区分大小写 |
trim-spaces | 是否去掉输入前后空格 |
cooldown-ms | 兑换冷却,毫秒 |
输入方式:
text
auto 高版本优先 Dialog,低版本自动回退
dialog 高版本原生 Dialog
book 书本输入
anvil 铁砧输入
chat 聊天输入推荐:
yaml
redeem:
default-input: "auto"
code-case-sensitive: false
trim-spaces: true
cooldown-ms: 1200如果服务器是低版本,可以指定:
yaml
redeem:
default-input: "book"security 防爆破
yaml
security:
anti-bruteforce:
enabled: true
window-seconds: 60
max-failures: 5
punish-seconds: 300
punish-actions:
- "[message] &c你输入错误次数过多,请稍后再试。"
- "[sound] ENTITY_VILLAGER_NO 1 1"| 字段 | 作用 |
|---|---|
enabled | 是否启用防爆破 |
window-seconds | 统计时间窗口 |
max-failures | 时间窗口内最大错误次数 |
punish-seconds | 惩罚持续时间 |
punish-actions | 触发惩罚时执行的动作 |
示例含义:
- 60 秒内输错 5 次。
- 进入 300 秒惩罚。
- 惩罚期间提示错误并播放声音。
推荐正式环境保持开启。
gui 默认 GUI
yaml
gui:
title: "&8GTCDK"
rows: 6
filler: "BLACK_STAINED_GLASS_PANE"
redeem-slot: 22
admin-slot: 49| 字段 | 作用 |
|---|---|
title | 默认 GUI 标题 |
rows | 默认 GUI 行数 |
filler | 默认填充物品 |
redeem-slot | 输入兑换码按钮槽位 |
admin-slot | 管理入口槽位 |
自定义 GUI 推荐写在 guis/ 文件夹中。config.yml 里的 GUI 是默认入口配置。
messages 提示消息
yaml
messages:
prefix: "&8[&bGTCDK&8] "
no-permission: "&c你没有权限。"
player-only: "&c只有玩家可以使用。"
reload: "&a配置已重载。"
input-tip: "&e请在聊天栏输入兑换码,输入 &c取消 &e可取消。"
cancelled: "&7已取消。"
redeem-success: "&a兑换成功。"
redeem-failed: "&c兑换失败:{reason}"
generated: "&a已生成 {count} 个兑换码,模板:{template}。"
deleted: "&a已删除 {count} 个兑换码。"
exported: "&a已导出到:{file}"常用变量:
text
{reason}
{count}
{template}
{file}templates 文件夹
CDK 模板放在:
text
plugins/GTCDK/templates/可以无限创建子文件夹:
text
plugins/GTCDK/templates/基础/开服礼包.yml
plugins/GTCDK/templates/高级/系数礼包.yml基础模板:
yaml
name: "&a开服礼包"
description:
- "&7输入 CDK 后领取一次。"
code:
prefix: "GT"
groups: 4
group-length: 4
charset: "ABCDEFGHJKLMNPQRSTUVWXYZ23456789"
separator: "-"
usage:
total: 1
per-player: 1
expire-seconds: 0
conditions:
- "%player_level% >= 0"
actions:
- "[item] DIAMOND 3"
- "[money] give 100"
- "[message] &a你领取了开服礼包。"
gui:
material: "CHEST"
slot: 20效果:
- 生成的 CDK 以
GT开头。 - 分成 4 组,每组 4 位。
- 每个 CDK 总共只能用 1 次。
- 每个玩家最多用 1 次。
- 兑换后给 3 个钻石、100 金币和提示消息。
exchanges 文件夹
兑换配置放在:
text
plugins/GTCDK/exchanges/兑换不需要 CDK,可以作为独立物品兑换系统使用。
yaml
name: "&b钻石兑换礼包"
description:
- "&7消耗 3 个钻石和 1 个绿宝石兑换奖励。"
conditions:
- "%player_level% >= 0"
actions:
- "[message] &a兑换成功,奖励已发放。"
- "[sound] ENTITY_PLAYER_LEVELUP 1 1"
exchange:
consume: true
cooldown-seconds: 3
materials:
- "DIAMOND 3"
- "EMERALD 1"
gui:
material: "DIAMOND"
slot: 22
rewards:
items: []效果:
- 玩家需要放入 3 个钻石和 1 个绿宝石。
- 成功后执行动作。
consume: true表示扣除材料。
guis 文件夹
GUI 配置放在:
text
plugins/GTCDK/guis/示例:
yaml
title: "&8GTCDK &7兑换中心"
rows: 6
commands: []
filler: "BLACK_STAINED_GLASS_PANE"
layout:
- "#########"
- "#R..E..A#"
- "#..S.L..#"
- "#.......#"
- "#.......#"
- "#########"
items:
"#":
material: "BLACK_STAINED_GLASS_PANE"
name: " "
R:
material: "PAPER"
name: "&a输入兑换码"
actions:
- "[redeem]"
E:
template: "物品兑换示例"
name: "&b物品兑换"
actions:
- "[exchange] 物品兑换示例"
A:
material: "COMMAND_BLOCK"
name: "&cCDK 管理"
permission: "gtcdk.admin"
actions:
- "admin"布局说明:
layout每行 9 个字符。- 每个字符对应
items下的一个按钮。 .通常表示空位。#常用作填充。
常用动作:
text
[redeem] 打开兑换码输入
[exchange] 兑换ID 执行兑换
[open] GUI_ID 打开另一个 GUI
admin 打开管理界面
[message] 文本 发送消息
[sound] 声音 音量 音调 播放声音常用完整方案
礼包 CDK
- 在
templates/基础/开服礼包.yml写模板。 - 进游戏打开管理 GUI。
- 选择模板。
- 批量生成 CDK。
- 玩家输入 CDK 领取奖励。
独立兑换系统
- 在
exchanges/副本/冰龙兑换.yml写兑换。 - 在
guis/ice_shop.yml做 GUI。 - 配置按钮动作
[exchange] 冰龙兑换。 - 玩家打开 GUI 后点击兑换。
验证流程
text
/gtcdk reload
/gtcdk检查:
- GUI 是否能打开。
- CDK 输入是否能弹出。
- 生成的 CDK 是否能兑换。
- 同一个 CDK 是否只能按模板次数使用。
- 兑换材料不足时是否正确提示。
- 连续输错是否触发防爆破。
