Skip to content

奖励配置

奖励系统用于配置地牢完成后或特定条件下发放的奖励,支持多种奖励类型和随机系统。

常见用途:

  • 地牢完成奖励(固定奖励)
  • Boss击杀奖励(随机奖励)
  • 评分奖励(根据表现)
  • 首通奖励(只给一次)
  • 活动礼包(特殊奖励)

前置要求:

  • 物品奖励需要正确的材料名
  • 金币奖励需要Vault和经济插件
  • MythicMobs物品需要MM插件

奖励类型说明

奖励系统支持多种奖励类型:

类型说明需要插件
原版物品Minecraft原版物品
MythicMobs物品MM自定义物品MythicMobs
经验值原版经验
金币经济系统金币Vault
控制台命令执行任意命令
随机奖励从多个选项中随机

示例1:固定奖励 - 基础礼包

给予固定数量的物品和金币。

yaml
rewards:
  基础奖励:
    items:
      - type: "item"
        id: "DIAMOND"
        amount: 5
      
      - type: "item"
        id: "EMERALD"
        amount: 10
      
      - type: "item"
        id: "GOLDEN_APPLE"
        amount: 3
    
    exp: 100      # 经验值
    money: 500    # 金币(需要Vault)
    
    commands:
      - "give %player% golden_apple 3"
      - "eco give %player% 500"

脚本中调用:

javascript
action.grant_reward('@all', '基础奖励')

示例2:MythicMobs物品奖励

包含自定义物品的奖励。

yaml
rewards:
  传说礼包:
    items:
      - type: "item"
        id: "DIAMOND_BLOCK"
        amount: 5
      
      - type: "mythic_item"
        id: "legendary_sword"  # MM物品ID
        amount: 1
      
      - type: "mythic_item"
        id: "legendary_armor"
        amount: 1
    
    exp: 500
    money: 2000

脚本中调用:

javascript
action.grant_reward('@all', '传说礼包')

示例3:随机奖励 - 随机礼包

从多个选项中随机选择一个。

yaml
rewards:
  随机礼包:
    type: "random"
    
    options:
      # 50% 概率 - 普通奖励
      普通:
        weight: 50
        items:
          - type: "item"
            id: "DIAMOND"
            amount: 3
          
          - type: "item"
            id: "GOLD_INGOT"
            amount: 10
        exp: 50
        money: 200
      
      # 30% 概率 - 稀有奖励
      稀有:
        weight: 30
        items:
          - type: "item"
            id: "EMERALD"
            amount: 5
          
          - type: "mythic_item"
            id: "rare_item"
            amount: 1
        exp: 100
        money: 500
      
      # 20% 概率 - 传说奖励
      传说:
        weight: 20
        items:
          - type: "mythic_item"
            id: "legendary_item"
            amount: 1
        exp: 200
        money: 1000
        commands:
          - "give %player% nether_star 1"

脚本中调用:

javascript
action.grant_reward('@all', '随机礼包')
action.message('@all', '&e每人获得了一份随机奖励!')

示例4:评分奖励 - 根据表现

根据玩家评分给予不同奖励。

yaml
rewards:
  # S级奖励
  评分_S级:
    items:
      - type: "mythic_item"
        id: "perfect_crystal"
        amount: 3
      
      - type: "item"
        id: "DIAMOND_BLOCK"
        amount: 10
    
    exp: 1000
    money: 5000
    
    commands:
      - "title %player% title {\"text\":\"S级评价\",\"color\":\"gold\",\"bold\":true}"
      - "give %player% nether_star 5"
  
  # A级奖励
  评分_A级:
    items:
      - type: "item"
        id: "DIAMOND"
        amount: 20
      
      - type: "mythic_item"
        id: "rare_crystal"
        amount: 2
    
    exp: 500
    money: 2000
  
  # B级奖励
  评分_B级:
    items:
      - type: "item"
        id: "DIAMOND"
        amount: 10
      
      - type: "item"
        id: "EMERALD"
        amount: 15
    
    exp: 200
    money: 1000

脚本中调用:

javascript
// 在 complete 脚本中
var score = calculateScore()  // 自定义计算函数

if (score >= 1500) {
  action.grant_reward('@all', '评分_S级')
  action.title('@all', '&6&l评价: S级', '&e完美通关')
} else if (score >= 1000) {
  action.grant_reward('@all', '评分_A级')
  action.title('@all', '&a&l评价: A级', '&e优秀表现')
} else {
  action.grant_reward('@all', '评分_B级')
  action.title('@all', '&b&l评价: B级', '&e继续加油')
}

示例5:首通奖励

只在第一次完成时给予特殊奖励(需要自行实现首通检测)。

yaml
rewards:
  首通奖励:
    items:
      - type: "item"
        id: "NETHER_STAR"
        amount: 1
      
      - type: "mythic_item"
        id: "first_clear_badge"
        amount: 1
      
      - type: "item"
        id: "DIAMOND_BLOCK"
        amount: 5
    
    exp: 1000
    money: 10000
    
    commands:
      - "broadcast &6&l恭喜 %player% 首次通关了地牢!"
      - "give %player% player_head{SkullOwner:\"%player%\"} 1"

脚本中调用:

javascript
// 在 complete 脚本中使用变量检测首通
var cleared = getVar('player_' + player.name + '_cleared') || 0

if (cleared === 0) {
  action.grant_reward('@all', '首通奖励')
  action.message('@all', '&6&l✦ 首次通关奖励已发放!')
  setVar('player_' + player.name + '_cleared', 1)
}

// 普通奖励
action.grant_reward('@all', '基础奖励')

示例6:活动礼包 - 限时双倍

包含大量奖励的活动礼包。

yaml
rewards:
  双倍活动礼包:
    items:
      - type: "item"
        id: "DIAMOND"
        amount: 20
      
      - type: "item"
        id: "EMERALD"
        amount: 30
      
      - type: "item"
        id: "GOLDEN_APPLE"
        amount: 10
      
      - type: "mythic_item"
        id: "event_token"
        amount: 5
    
    exp: 1000
    money: 5000
    
    commands:
      - "give %player% experience_bottle 64"
      - "title %player% subtitle {\"text\":\"双倍奖励活动中\",\"color\":\"yellow\"}"

示例7:小概率大奖 - 彩票系统

极低概率获得超级奖励。

yaml
rewards:
  幸运抽奖:
    type: "random"
    
    options:
      # 70% - 安慰奖
      安慰奖:
        weight: 70
        items:
          - type: "item"
            id: "GOLD_INGOT"
            amount: 5
        money: 100
      
      # 25% - 普通奖
      普通奖:
        weight: 25
        items:
          - type: "item"
            id: "DIAMOND"
            amount: 3
        money: 500
      
      # 4% - 稀有奖
      稀有奖:
        weight: 4
        items:
          - type: "mythic_item"
            id: "rare_weapon"
            amount: 1
        money: 2000
      
      # 1% - 超级大奖
      超级大奖:
        weight: 1
        items:
          - type: "mythic_item"
            id: "legendary_weapon"
            amount: 1
          
          - type: "item"
            id: "DIAMOND_BLOCK"
            amount: 64
        money: 50000
        commands:
          - "broadcast &6&l★ 恭喜 %player% 抽中了超级大奖!"

示例8:多重随机奖励

多次随机抽取奖励。

yaml
rewards:
  三连抽:
    type: "random"

    options:
      铁锭:
        weight: 40
        items:
          - type: "item"
            id: "IRON_INGOT"
            amount: 10

      金锭:
        weight: 35
        items:
          - type: "item"
            id: "GOLD_INGOT"
            amount: 5

      钻石:
        weight: 20
        items:
          - type: "item"
            id: "DIAMOND"
            amount: 2

      绿宝石:
        weight: 5
        items:
          - type: "item"
            id: "EMERALD"
            amount: 3

脚本中调用(抽3次):

javascript
action.message('@all', '&e三连抽开始!')
action.grant_reward('@all', '三连抽')
action.wait('1秒')
action.grant_reward('@all', '三连抽')
action.wait('1秒')
action.grant_reward('@all', '三连抽')
action.message('@all', '&a三连抽完成!')

箱子奖励UI系统 🆕

箱子奖励UI系统允许玩家在地牢中与箱子交互时,打开一个自定义界面选择想要的奖励。

功能特点

  • 🎁 可视化选择 - 玩家通过UI界面选择奖励,而不是直接发放
  • 🎨 完全可配置 - 自定义UI标题、行数、背景、图标
  • 🔒 防重复领取 - 配合 once: true 防止重复领取
  • 🎯 多种模式 - 支持单选、多选、全部领取模式
  • 🎲 随机抽奖 - 支持随机奖励抽奖效果

配置文件

箱子UI配置在地牢的 chest_rewards.yml 文件中。

示例1:基础宝箱UI

最简单的宝箱,玩家可以从3个奖励中选择1个。

chest_rewards.yml:

yaml
chests:
  normal_chest:
    title: "&6&l✦ 普通宝箱 ✦"
    rows: 3
    mode: single  # 只能选择一个奖励
    background: BLACK_STAINED_GLASS_PANE

    options:
      - slot: 11
        icon: DIAMOND
        name: "&b钻石礼包"
        lore:
          - ""
          - "&7包含:"
          - "&8▸ &f钻石 x3"
          - "&8▸ &f绿宝石 x5"
          - "&8▸ &6金币 +1000"
          - ""
          - "&e▸ 左键点击领取"
        reward: "normal_reward"  # 关联 rewards.yml 中的奖励

      - slot: 13
        icon: GOLD_INGOT
        name: "&e金币礼包"
        lore:
          - ""
          - "&7包含:"
          - "&8▸ &f金锭 x16"
          - "&8▸ &6金币 +2000"
          - ""
          - "&e▸ 左键点击领取"
        reward: "gold_pack"

      - slot: 15
        icon: EXPERIENCE_BOTTLE
        name: "&a经验礼包"
        lore:
          - ""
          - "&7包含:"
          - "&8▸ &a经验 +1000"
          - "&8▸ &6金币 +500"
          - ""
          - "&e▸ 左键点击领取"
        reward: "exp_pack"

interacts.yml:

yaml
interacts:
  reward_chest_1:
    type: "RIGHT_CLICK_BLOCK"
    once: true  # 每个玩家只能打开一次

    parameters:
      location: "15,64,0"
      block_type: "CHEST"

    triggered_message: "&c你已经打开过这个宝箱了"

    script: |-
      action.message('@trigger', '&a&l你打开了宝箱!')
      action.sound('@trigger', 'BLOCK_CHEST_OPEN', 1.0, 1.0)

      // 打开箱子奖励UI
      action.open_chest_ui('@trigger', 'normal_chest')

示例2:Boss战利品宝箱

更高级的宝箱,包含多个稀有奖励选项。

chest_rewards.yml:

yaml
chests:
  boss_chest:
    title: "&c&l✦ Boss战利品 ✦"
    rows: 5
    mode: single
    background: RED_STAINED_GLASS_PANE

    options:
      - slot: 13
        icon: NETHERITE_SWORD
        name: "&c&l神话级武器"
        lore:
          - ""
          - "&d&l特殊奖励"
          - ""
          - "&7包含:"
          - "&8▸ &cBoss战利品 x1"
          - "&8▸ &5下界合金 x3"
          - "&8▸ &6金币 +30000"
          - ""
          - "&e▸ 左键点击领取"
        reward: "perfect_clear_reward"

      - slot: 21
        icon: GOLDEN_APPLE
        name: "&6幸运礼包"
        lore:
          - ""
          - "&7包含:"
          - "&8▸ &e金苹果 x5"
          - "&8▸ &a经验瓶 x16"
          - "&8▸ &6金币 +2000"
          - ""
          - "&e▸ 左键点击领取"
        reward: "lucky_pack"

      - slot: 23
        icon: DIAMOND
        name: "&b珍贵材料"
        lore:
          - ""
          - "&7包含:"
          - "&8▸ &b钻石块 x5"
          - "&8▸ &f绿宝石 x32"
          - "&8▸ &6金币 +5000"
          - ""
          - "&e▸ 左键点击领取"
        reward: "boss_kill_reward"

interacts.yml:

yaml
interacts:
  boss_chest:
    type: "RIGHT_CLICK_BLOCK"
    once: true

    parameters:
      location: "0,64,20"

    triggered_message: "&c你已经领取过Boss奖励了"

    script: |-
      action.title('@trigger', '&d&lBOSS战利品', '&7选择你的奖励')
      action.sound('@trigger', 'BLOCK_CHEST_OPEN', 1.0, 0.8)
      action.effect('DRAGON_BREATH', '0,65,20', 30, 1.0, 0.5)

      // 打开稀有宝箱UI
      action.open_chest_ui('@trigger', 'boss_chest')

示例3:随机抽奖宝箱

使用随机奖励实现抽奖效果。

chest_rewards.yml:

yaml
chests:
  mystery_chest:
    title: "&5&l✦ 神秘宝箱 ✦"
    rows: 3
    mode: single

    options:
      - slot: 13
        icon: ENDER_CHEST
        name: "&5&l??? 未知奖励 ???"
        lore:
          - ""
          - "&d打开后会发生什么?"
          - "&d谁也不知道..."
          - ""
          - "&7也许是好东西?"
          - "&7也许是坏东西?"
          - ""
          - "&c&l你敢点击吗?"
          - ""
          - "&e▸ 左键点击领取"
        reward: "random_pack"  # 使用 rewards.yml 中的随机奖励

配置字段说明

chest_rewards.yml 字段

字段类型必填说明
标题/title字符串UI标题(支持颜色代码 &)
行数/rows整数UI行数(1-6)
模式/mode字符串选择模式(single/multiple/all)
背景/background字符串背景填充方块
选项/options列表奖励选项列表

options 字段

字段类型必填说明
槽位/slot整数物品所在槽位(0-53)
图标/icon字符串显示的物品材料名
名称/name字符串显示名称(支持颜色代码 &)
描述/lore列表描述文本列表
奖励/reward字符串关联的奖励名称(来自 rewards.yml)

脚本命令

javascript
// 打开箱子UI给触发者
action.open_chest_ui('@trigger', '箱子ID')

// 打开箱子UI给所有玩家
action.open_chest_ui('@all', '箱子ID')

// 打开箱子UI给队伍
action.open_chest_ui('@party', '箱子ID')

使用流程

  1. chest_rewards.yml 中配置箱子UI
  2. rewards.yml 中配置对应的奖励
  3. interacts.yml 中创建交互点,脚本中调用 action.open_chest_ui()
  4. 使用 /dga reload 重载配置
  5. 在地牢中放置箱子方块,右键打开

完整示例

1. chest_rewards.yml:

yaml
chests:
  hidden_chest:
    title: "&5&l✦ 隐藏宝箱 ✦"
    rows: 3
    mode: single
    background: PURPLE_STAINED_GLASS_PANE

    options:
      - slot: 11
        icon: DIAMOND
        name: "&b传说装备"
        lore: ["&7获得传说装备"]
        reward: "legendary_pack"

      - slot: 13
        icon: GOLD_INGOT
        name: "&e大量金币"
        lore: ["&7获得大量金币"]
        reward: "speedrun_reward"

      - slot: 15
        icon: ENDER_PEARL
        name: "&d神秘抽奖"
        lore: ["&7随机获得奖励"]
        reward: "random_pack"

2. rewards.yml:

yaml
rewards:
  legendary_pack:
    items:
      - type: mythic_item
        id: "legendary_sword"
        amount: 1
    money: 10000

  speedrun_reward:
    money: 20000
    exp: 5000

  random_pack:
    type: random
    options:
      钻石:
        weight: 50
        items:
          - type: item
            id: DIAMOND
            amount: 5
      金币:
        weight: 50
        money: 1000

3. interacts.yml:

yaml
interacts:
  hidden_chest:
    type: "RIGHT_CLICK_BLOCK"
    once: true
    parameters:
      location: "30,64,10"
    script: |-
      action.sound('@trigger', 'BLOCK_CHEST_OPEN', 1.0, 1.0)
      action.open_chest_ui('@trigger', 'hidden_chest')

槽位布局参考

3行界面(27个槽位):

[0]  [1]  [2]  [3]  [4]  [5]  [6]  [7]  [8]
[9]  [10] [11] [12] [13] [14] [15] [16] [17]
[18] [19] [20] [21] [22] [23] [24] [25] [26]

常用居中槽位:

  • 3行: 槽位 11, 13, 15(第二行中间3个)
  • 4行: 槽位 12, 14, 21, 23
  • 5行: 槽位 13, 21, 22, 23

常见问题

Q: 箱子UI不显示?

  • 确认 chest_rewards.yml 存在且配置正确
  • 检查箱子ID是否与脚本中的一致
  • 查看控制台是否有配置加载错误

Q: 点击奖励没反应?

  • 确认 rewards.yml 中存在对应的奖励
  • 检查奖励名称是否完全一致(区分大小写)
  • 查看控制台是否有奖励发放错误

Q: 如何防止重复领取?

  • 交互点设置 once: true
  • 每个玩家只能触发一次
  • 重复点击会显示 triggered_message

Q: 可以给队伍所有人打开UI吗?

  • 可以!使用 action.open_chest_ui('@all', '箱子ID')
  • 每个玩家会独立看到UI并选择奖励
  • 配合 once: true 每人只能选一次

配置字段说明

固定奖励字段

字段类型必填说明
items列表物品列表
exp整数经验值
money整数金币(需要Vault)
commands列表控制台命令列表

items 字段

字段类型必填说明
type字符串"item" 或 "mythic_item"
id字符串物品ID(材料名或MM物品ID)
amount整数数量

随机奖励字段

字段类型必填说明
type字符串必须为 "random"
options列表随机选项列表

options 字段

字段类型必填说明
weight整数权重(数值越大概率越高)
items列表物品列表
exp整数经验值
money整数金币
commands列表控制台命令

配置文件编辑

奖励配置只能通过配置文件编辑,没有游戏内UI。

编辑步骤

  1. 打开 plugins/QueDP/dungeons/地牢名/rewards.yml
  2. 按照示例格式添加奖励
  3. 使用 /dga reload 重载配置
  4. 在脚本中使用 action.grant_reward('@selector', '奖励名') 调用

配置技巧

物品配置:

  • type: "item" - 原版物品,id使用材料名(如DIAMOND)
  • type: "mythic_item" - MM物品,id使用MM配置的物品ID
  • 所有物品都在 items 列表中,用 type 区分

随机奖励:

  • weight 是相对权重,不是百分比
  • 总权重 = 所有选项的weight之和
  • 单个选项概率 = weight / 总权重
  • 示例:weight为[50, 30, 20],概率为[50%, 30%, 20%]

命令占位符:

  • %player% - 玩家名称
  • 可以使用任何控制台命令
  • 命令按顺序执行

常见问题

Q: 奖励不发放?

  • 检查奖励名称是否正确
  • 确认脚本中调用的名称与配置一致
  • 查看控制台是否有错误日志

Q: 物品ID错误?

  • 原版物品使用大写材料名(如 DIAMOND
  • MM物品使用MM配置中的物品ID
  • 检查 type 是否正确("item" 或 "mythic_item")

Q: 金币不发放?

  • 确认服务器已安装Vault和经济插件
  • 检查经济插件是否正常工作
  • 尝试手动执行 /eco give 玩家名 金额 测试

Q: 随机奖励总是一样?

  • 随机系统正常工作,可能是运气问题
  • 检查权重配置是否合理
  • 可以添加调试信息查看抽中结果

Q: 如何测试随机概率?

  • 多次调用奖励查看分布
  • 使用较大的权重差异便于观察
  • 示例:[80, 15, 5] 比 [34, 33, 33] 更容易看出差异

Q: 可以给单个玩家发奖励吗?

  • 可以!使用 @trigger 选择器
  • 示例:action.grant_reward('@trigger', '个人奖励')
  • 也可以使用 @random 给随机玩家

高级技巧

1. 条件奖励

根据条件发放不同奖励。

javascript
// 在 complete 脚本中
var time = dungeon.time
var deaths = getVar('team_deaths') || 0

if (time < 600 && deaths === 0) {
  // 10分钟内无死亡 - 完美通关
  action.grant_reward('@all', '完美通关奖励')
} else if (time < 1200) {
  // 20分钟内完成
  action.grant_reward('@all', '快速通关奖励')
} else {
  // 普通完成
  action.grant_reward('@all', '基础奖励')
}

2. 累计奖励

完成多次后给予额外奖励(使用变量追踪)。

javascript
// 在 complete 脚本中
var completions = (getVar('player_' + player.name + '_completions') || 0) + 1
setVar('player_' + player.name + '_completions', completions)

action.grant_reward('@all', '基础奖励')

// 每10次完成给额外奖励
if (completions % 10 === 0) {
  action.grant_reward('@all', '里程碑奖励')
  action.message('@all', '&6&l✦ 完成' + completions + '次!获得里程碑奖励')
}

3. 时间限制奖励

根据完成时间给予额外奖励。

javascript
// 在 complete 脚本中
var time = dungeon.time

// 基础奖励给所有人
action.grant_reward('@all', '基础奖励')

// 根据时间给额外奖励
if (time < 300) {
  action.grant_reward('@all', '速通奖励')
  action.message('@all', '&6&l✦ 5分钟速通!获得额外奖励')
} else if (time < 600) {
  action.grant_reward('@all', '快速奖励')
  action.message('@all', '&a10分钟快速完成!获得额外奖励')
}

基于 MIT 许可发布