奖励与变量
奖励写在模板的 rewards 下。r1、r2、r3 等一级节点都是奖励组。
原来的单奖励写法继续有效。下面的 r1 和 r2 都没有填写 chance,因此每次采集都会同时执行:
rewards:
r1:
id: DIAMOND
amount: "1"
mode: INVENTORY
r2:
command:
- "console:xp give %player% 5"奖励组概率
在奖励组内填写 chance 可以参加权重抽取:
chance 结果 | 执行方式 |
|---|---|
不写或大于等于 100 | 必定执行;多个必定组会在同一次采集中全部执行 |
0 或负数 | 不执行 |
大于 0 且小于 100 | 进入权重池;每次采集从权重池中抽取一组 |
权重池使用所有候选组的 chance 总和计算。六个组都填写 20 时,总权重是 120,每组被抽中的比例是 20 / 120。
下面的配置会必定执行 guaranteed,然后从 r1 和 r2 中抽取一组:
rewards:
guaranteed:
command:
- "console:xp give %player% 5"
r1:
chance: 20
1:
id: RAW_IRON
amount: "1"
mode: INVENTORY
2:
id: COAL
amount: "2"
mode: INVENTORY
3:
command:
- "console:eco give %player% 10"
r2:
chance: 20
command:
- "console:eco give %player% 30"r1 被抽中时,其内部的 1、2、3 会按顺序全部执行。组内奖励和普通奖励使用同一套字段,因此仍支持原版、NI、MM 物品、amount、mode、command、message 和 condition。
TIP
如果权重池里只有一个有效组,它的比例就是“自身权重 / 自身权重”,因此每次都会被抽中。需要真正的随机分支时,至少配置两个大于 0 且小于 100 的组。
PAPI 动态权重
chance 支持 PAPI 和算术表达式,并在每次采集结算时按当前玩家计算:
rewards:
normal:
chance: 20
id: IRON_INGOT
amount: "1"
level_bonus:
chance: "20 + %player_level% / 10"
id: DIAMOND
amount: "1"玩家等级变化后,level_bonus 的权重也会变化。表达式结果达到 100 时,该组会变成必定组;结果为 0 时不会触发。
原版物品奖励
直接写 Material:
rewards:
r1:
id: DIAMOND
amount: "1"
mode: INVENTORY效果:采集后给玩家 1 个钻石。
掉落到地上:
rewards:
r1:
id: RAW_IRON
amount: "3"
mode: DROPmode 常用值:
| 值 | 效果 |
|---|---|
INVENTORY | 直接进入背包 |
DROP | 掉落在采集点位置 |
物品库奖励
NeigeItems:
rewards:
r1:
id: "ni:ruby"
amount: "1"
mode: INVENTORYMythicMobs:
rewards:
r1:
id: "mm:LEGEND_SWORD"
amount: "1"
mode: DROP写法规则:
| 前缀 | 内容 |
|---|---|
| 无前缀 | 原版 Material |
ni: | NeigeItems 物品 |
mm: | MythicMobs 物品 |
命令奖励
rewards:
r1:
command:
- "console:eco give %player% 100"
- "console:xp give %player% 5"
- "player:me 完成了一次采集"命令身份:
| 前缀 | 执行方式 |
|---|---|
console: | 控制台执行 |
player: | 玩家自己执行 |
op: | 玩家临时 OP 执行 |
有些插件不支持控制台执行指令,可以用 op::
command:
- "op:someplugin reward %player%"命令奖励提示
命令奖励可以自定义提示:
rewards:
r1:
command:
- "console:eco give %player% 100"
message:
- "&a采集成功"
- "&7获得金币:&e100"如果不写 message,会使用主配置里的默认奖励提示。
数量公式
amount 支持数字、PAPI 和算术表达式。
等级越高给得越多:
rewards:
r1:
id: DIAMOND
amount: "1 + %player_level% / 10"
mode: INVENTORY活动倍率:
rewards:
r1:
id: RAW_IRON
amount: "2 * %server_gt_event_rate%"
mode: INVENTORYVIP 倍率:
rewards:
r1:
id: EMERALD
amount: "1 + %vault_rank_weight%"
mode: INVENTORY变量返回值必须能转成数字。变量为空或不是数字时,先用 PAPI 测试命令确认返回值。
条件奖励
每条奖励都可以单独写 condition。旧式单奖励组直接把 condition 写在组下;嵌套组则写在具体的 1、2、3 奖励下。没有写 condition 的奖励会一直执行。
职业奖励:
rewards:
r1:
id: "ni:warrior_sword"
amount: "1"
condition: "%player_class% == WARRIOR"
r2:
id: "ni:apprentice_wand"
amount: "1"
condition: "%player_class% == MAGE"
r3:
id: STICK
amount: "1"效果:
- 战士获得
ni:warrior_sword。 - 法师获得
ni:apprentice_wand。 - 所有人都会额外获得 1 根木棍。
复杂条件
支持 &&、||、! 和括号:
condition: "(%player_class% == WARRIOR || %player_class% == MAGE) && %player_level% >= 30"只允许主世界:
condition: "%player_world% == world"只允许拥有权限变量的玩家:
condition: "%player_has_permission_gtgather.vip% == 1"采集条件和奖励条件的区别
| 位置 | 作用 |
|---|---|
triggers | 决定玩家能不能开始采集 |
rewards.<组>.condition 或 rewards.<组>.<项>.condition | 决定某条奖励是否发放 |
例子:所有人都能采集,但 VIP 多拿 1 个钻石:
rewards:
normal:
id: DIAMOND
amount: "1"
vip:
id: DIAMOND
amount: "1"
condition: "%player_has_permission_gtgather.vip% == 1"常用变量
玩家变量
%player_name%
%player_level%
%player_world%
%player_x%
%player_y%
%player_z%冷却变量
%gtgather_cooldown%
%gtgather_cooldown_<spawnId>%
%gtgather_cooldown_raw_<spawnId>%
%gtgather_cooldown_tpl_<templateId>%冷却变量适合写在菜单、计分板、提示文字里。
完整示例:职业奖励点
templates:
branched_reward:
display: "§6§l职业奖励点"
entity-type: TEXT_DISPLAY
description:
- "§6战士: 剑"
- "§b法师: 法杖"
- "§7其他: 通用奖励"
rewards:
warrior:
id: "ni:warrior_sword"
amount: "1"
mode: INVENTORY
condition: "%player_class% == WARRIOR"
mage:
id: "ni:apprentice_wand"
amount: "1"
mode: INVENTORY
condition: "%player_class% == MAGE"
common:
id: STICK
amount: "1"
mode: INVENTORY
money:
command:
- "console:eco give %player% 100"
message:
- "&a采集完成"
- "&7金币:&e100"完整示例:等级缩放矿
templates:
level_scaled:
display: "§a§l等级缩放矿"
entity-type: ARMOR_STAND
display-item: DIAMOND_ORE
description:
- "§7等级越高,奖励越多"
cast:
enabled: true
duration: "3.0"
cooldown: "20s"
rewards:
r1:
id: DIAMOND
amount: "1 + %player_level% / 10"
mode: INVENTORY
r2:
command:
- "console:xp give %player% 5"排查奖励
奖励没发:
- 开启
debug.log-reward。 - 先用原版
DIAMOND测试。 - 检查
ni:、mm:物品 ID 是否真实存在。 - 检查
chance的 PAPI 表达式实际返回值;结果为0的组不会执行。 - 确认该组是必定组,还是权重池里本次没有抽中的组。
- 检查
condition是否返回 true。 - 检查玩家背包是否满。
条件奖励不触发:
- 用 PAPI 测试命令看变量实际返回值。
- 字符串条件按实际返回值写。
- 复杂条件先拆成多条简单条件测试。
命令奖励不执行:
- 把命令单独放到控制台测试。
- 不要在命令前写
/。 - 插件不支持控制台时改用
op:。 - 确认
%player%是否被正确替换。
