商品配置
商品定义文件位于 goods/ 目录下,每个 YAML 文件中的顶层 key 就是全局唯一的商品 ID。你可以在商店配置的 goods 列表中通过这个 ID 来引用商品。
基本结构
# 商品 ID(全局唯一)
diamond_sword_basic:
give:
mode: source
actions: |-
tell color inline "&a成功购买 &f{{ &display-name }} &ax{{ &amount }}"
tell color inline "消费 &e{{ &price }} &f金币"
display:
material: "diamond sword"
name: '&b钻石剑'
model-data: 0
mode: overwrite
lore:
- '&7一把普通的钻石剑'
- ''
- '&e价格: {price} 金币'
tags:
- 武器
- 钻石
6 种给予模式 (give.mode)
通过 give.mode 字段控制玩家购买后获得什么。
| 模式 | 说明 |
|---|---|
none | 不给物品,仅执行 actions 脚本。适用于 VIP、权限、经验等服务类商品 |
source | 给予物品源(material)生成的原始物品 |
display | 给予 GUI 中展示的完整物品(包含所有 display 修改) |
ignore_lore | 给予物品源物品,但仅修改 name,保留原始 lore |
ignore_name | 给予物品源物品,但仅修改 lore,保留原始 name |
attribute | Hook AttributePlus / SX-Attribute 属性系统,给予永久或临时属性 |
none 模式 -- 服务类商品
不给予任何物品,购买后仅执行 Kether 脚本。适合 VIP 购买、权限购买、经验购买等场景。
vip_7day:
give:
mode: none
# Kether 脚本
# 支持变量:
# {{ &amount }} 购买数量
# {{ &price }} 单价
# {{ &display-name }} 商品显示名
# {{ sender }} 购买者名称
actions: |-
command inline "lp user {{ sender }} permission settemp vip.member true 7d" as console
tell color inline "&a&l恭喜! &f你已获得 &e7天VIP &f权限"
title inline "&6&lVIP 激活" inline "&7有效期 7 天" 20 40 20
display:
material: "nether star"
name: '&e&l7天VIP会员卡'
model-data: 0
mode: overwrite
lore:
- '&7&m―――――――――――――――'
- '&e特权:'
- ' &f- 专属 VIP 商店折扣'
- ' &f- 每日领取奖励'
- ' &f- 飞行权限'
- '&7&m―――――――――――――――'
- ''
- '&e价格: {price} 点券'
tags:
- VIP
- 权限
source 模式 -- 给予原始物品
给予物品源(material 字段指定的物品)生成的原始物品,不做任何修改。
diamond_sword_basic:
give:
mode: source
actions: |-
tell color inline "&a成功购买 &f{{ &display-name }} &ax{{ &amount }}"
tell color inline "消费 &e{{ &price }} &f金币"
display:
material: "diamond sword"
name: '&b钻石剑'
model-data: 0
mode: overwrite
lore:
- '&7一把普通的钻石剑'
- ''
- '&e价格: {price} 金币'
tags:
- 武器
- 钻石
display 模式 -- 给予展示物品
给予 GUI 中展示的完整物品,包含所有 display 中的修改(name、lore、nbt 等)。
mm_legendary_sword:
give:
mode: display
actions: |-
tell color inline "&6&l恭喜获得传说武器 &f{{ &display-name }}"
command inline "effect give {{ sender }} minecraft:glowing 10 1" as console
display:
material: "mm: 传说之剑"
name: '&6&l传说之剑 &7- &e限定版'
model-data: 20001
color: '255,215,0'
mode: overwrite
lore:
- '&7&m―――――――――――――――'
- '&c攻击力 +150'
- '&e暴击率 +25%'
- '&7&m―――――――――――――――'
- ''
- '&6&l传说品质'
- '&e价格: {price} 金币'
nbt:
malkuth_source: legendary_sword
custom_rarity: legendary
tags:
- 武器
- 传说
- 限定
ignore_lore 模式 -- 仅修改名称
给予物品源物品,但仅修改 name,保留物品源的原始 lore。
repair_stone:
give:
mode: ignore_lore
modify:
name: '&a修复之石 &7(已购买)'
actions: |-
tell color inline "&a获得修复之石 x{{ &amount }}"
display:
material: "mm: 修复之石"
name: '&a修复之石'
mode: add
lore:
- ''
- '&7右键点击装备进行修复'
- '&e价格: {price} 金币'
tags:
- 材料
- 修复
ignore_name 模式 -- 仅修改描述
给予物品源物品,但仅修改 lore,保留物品源的原始 name。
enchant_scroll:
give:
mode: ignore_name
modify:
lore:
mode: add
texts:
- ''
- '&7购买自 Malkuth 商城'
- '&7购买时间: 不可追溯'
actions: |-
tell color inline "&a获得附魔卷轴 x{{ &amount }}"
display:
material: "mm: 附魔卷轴"
name: '&d附魔卷轴'
mode: overwrite
lore:
- '&7使用后随机附魔一件装备'
- ''
- '&e价格: {price} 金币'
tags:
- 材料
- 附魔
attribute 模式 -- 属性商品
Hook AttributePlus 或 SX-Attribute 属性系统,给予玩家永久属性或临时属性。
属性1:
give:
mode: attribute
attribute:
# 启用多个属性时选用一个
# ap AttributePlus
# sx Sx-Attribute
hook: ap
# 永久属性,连接同一个数据库后可跨服同步属性
persistence:
- '攻击力: 10'
# 临时属性
temporary:
# 7天属性
'7d':
- '防御力: 10'
# 2小时属性
'2h':
- '移动速度: 1'
display:
mode: add
material: "mm: 强化宝石"
name: '传说属性'
model-data: 10001
color: '255,255,255'
lore:
- "可获得永久属性"
- "限时属性 7天"
- "价格 {price}"
- "购买 {amount} 个"
| 字段 | 说明 |
|---|---|
attribute.hook | 属性插件选择:ap(AttributePlus)或 sx(SX-Attribute) |
attribute.persistence | 永久属性列表,跨服同步(需连接同一数据库) |
attribute.temporary | 临时属性,key 为持续时间(如 7d、2h),value 为属性列表 |
物品源 (display.material)
display.material 字段决定了商品使用的物品。当前源码共注册 33 个固定物品源 + 1 个条件物品源(mod,仅 Mod 服务器生效):
| 前缀 | 物品源功能说明 | 示例 |
|---|---|---|
(无前缀) / mc: / eq: / equip: | Minecraft 原版 | "diamond_sword" |
repo: | Malkuth Repository | "repo:my_item" |
mm: / mythic: | MythicMobs | "mm: 传说之剑" |
ia: | ItemsAdder | "ia: 物品ID" |
ni: | NeigeItems | "ni: 物品ID" |
mi: / mmo: | MMOItems | "mi:装备类型,id" |
ox: | Oraxen | "ox: 物品ID" |
zap: / zl: | Zaphkiel | "zap: 测试物品" |
ce: | CraftEngine | "ce: 物品ID" |
bkr: / bai: | Baikiruto | "bkr: 物品ID" |
da: / armourers: | DragonArmourers | "da: 物品ID" |
sx: | SX-Item | "sx: 物品ID" |
sf: | Slimefun | "sf: 物品ID" |
hdb: / head: | HeadDatabase | "hdb: 物品ID" |
ei: | ExecutableItems | "ei: 物品ID" |
px: | PxRpg | "px: 物品ID" |
af: | AzureFlow | "af: 物品ID" |
mg: | MagicGem | "mg: 物品ID" |
rz: | Ratziel | "rz: 物品ID" |
cf: | CustomFishing | "cf: 物品ID" |
nx: | Nexo | "nx: 物品ID" |
nova: | Nova | "nova: 物品ID" |
hmc: | HMCCosmetics | "hmc: 物品ID" |
st: | Sertraline | "st: 物品ID" |
ecoarmor: | EcoArmor | "ecoarmor: item_id" |
ecocrates: | EcoCrates | "ecocrates: item_id" |
ecoitems: | EcoItems | "ecoitems: item_id" |
ecomobs: | EcoMobs | "ecomobs: item_id" |
ecopets: | EcoPets | "ecopets: item_id" |
ecoscrolls: | EcoScrolls | "ecoscrolls: item_id" |
reforges: | Reforges | "reforges: item_id" |
stattrackers: | StatTrackers | "stattrackers: item_id" |
talismans: | Talismans | "talismans: item_id" |
mod: | Mod 物品(仅 Mod 服务器) | "mod: modid:item_id" |
display 配置
display 节点控制商品在 GUI 中的展示效果。
| 字段 | 说明 |
|---|---|
material | 物品源,支持上述所有前缀 |
name | 显示名称。留空或不写则不变。支持 {name} 引用原始名称 |
model-data | CustomModelData 数值 |
color | RGB 颜色(如 '255,215,0'),用于支持 RGB 颜色的物品(皮革装备、药水等) |
mode | lore 编辑模式 |
lore | lore 内容列表 |
nbt | 自定义 NBT 标签 |
lore 编辑模式 (mode)
| 模式 | 说明 |
|---|---|
overwrite | 覆盖物品源的 lore,使用 display 中定义的 lore |
add | 在物品源 lore 最后追加 |
clear | 清空所有 lore |
insert:N | 在第 N 行插入 lore |
display 变量
你可以在 display 的 name 和 lore 中使用以下变量:
| 变量 | 说明 |
|---|---|
{name} | 物品源的原始名称 |
{price} | 商品价格;纯物品购买模式下会显示所需物品描述 |
{amount} | 购买数量 |
{has_currency} | 玩家当前货币余额;纯物品购买模式下会显示已满足的物品数量 |
{limit} / {limit_remaining} | 商品剩余可购买数量 |
{buy_mode} | 当前购买模式文本(货币 / 物品 / 混合) |
{buy_items} | 当前商品的物品需求描述 |
{buy_items_N} | 第 N 条物品需求描述,N 从 1 开始 |
{currency_type} | 当前生效货币标识;商品级货币覆盖后也会跟着变化 |
{lore} | 物品源的全部 lore |
{lore_N} | 物品源第 N 组 lore |
{material} | 物品源的原始材质(可用于 material 字段中,如 "red {material}") |
{shop_player_current} | 商店级个人已购数量 |
{shop_player_max} | 商店级个人最大限制 |
{shop_player_remaining} | 商店级个人剩余额度 |
{shop_global_current} | 商店级全局已购数量 |
{shop_global_max} | 商店级全局最大限制 |
{shop_global_remaining} | 商店级全局剩余额度 |
{goods_player_current} | 商品级个人已购数量 |
{goods_player_max} | 商品级个人最大限制 |
{goods_player_remaining} | 商品级个人剩余额度 |
{goods_global_current} | 商品级全局已购数量 |
{goods_global_max} | 商品级全局最大限制 |
{goods_global_remaining} | 商品级全局剩余额度 |
五模板变量常用
| 变量 | 功能说明 |
|---|---|
{name} | 显示原物品名或当前模板上下文中的商品名,适合做标题主字段 |
{price} | 当前实际购买单价(含条件价/动态价结果) |
{amount} | 当前交易数量(支持 buy-actions 快捷购买数量) |
{has_currency} | 玩家在该商店货币体系下的实时余额 |
{limit_remaining} | 当前玩家剩余可购买数量({limit} 的同义变量) |
如需展示限额进度,可直接组合使用 {shop_player_current} / {shop_player_max}、{shop_global_current} / {shop_global_max}、{goods_player_current} / {goods_player_max}、{goods_global_current} / {goods_global_max} 等明细变量。
lore 编辑模式示例
overwrite -- 覆盖
oak_planks:
give:
mode: source
display:
material: "oak planks"
name: '&f橡木板'
mode: overwrite
lore:
- '&7基础建筑方块'
- '&e价格: {price} 金币'
add -- 追加
stone_bricks:
give:
mode: source
display:
material: "stone bricks"
name: '&8石砖'
mode: add
lore:
- ''
- '&e价格: {price} 金币'
clear -- 清空
barrier_block:
give:
mode: source
display:
material: "barrier"
name: '&c屏障方块'
mode: clear
lore: []
insert:N -- 插入
glass_block:
give:
mode: source
display:
material: "glass"
name: '&f玻璃'
mode: "insert:1"
lore:
- '&7--- 商城购买 ---'
- '&e价格: {price} 金币'
购买后修改 (give.modify)
你可以通过 give.modify 对购买后给予的物品进行二次修改。
diamond_sword_enhanced:
give:
mode: source
modify:
# {name} 引用生成默认物品的 name
name: '&6&l锻造 {name}'
lore:
# mode 与 display.mode 一致: overwrite / add / clear / insert:N
mode: add
texts:
- ''
- '&d已锻造强化'
- '&7购买自 Malkuth 商城'
display:
material: "diamond sword"
name: '&6锻造钻石剑'
model-data: 10002
mode: overwrite
lore:
- '&7经过锻造的钻石剑'
- '&7购买后会附加锻造标记'
- ''
- '&e价格: {price} 金币'
| 字段 | 说明 |
|---|---|
modify.name | 修改物品名称,{name} 引用原始物品名称 |
modify.lore.mode | lore 修改模式:overwrite / add / clear / insert:N |
modify.lore.texts | 要修改/追加的 lore 内容列表 |
actions 脚本
actions 字段定义购买成功后执行的 Kether 脚本。
可用变量
| 变量 | 说明 |
|---|---|
{{ &amount }} | 本次实际发放数量(已乘以购买数量与打包数量) |
{{ &purchase-count }} | 本次购买次数(点击购买数量) |
{{ &price }} | 当前生效单价 |
{{ &total-price }} | 本次总价 |
{{ &display-name }} | 当前发放商品的显示名 |
{{ ¤cy }} | 当前货币模式(如 vault / %papi_var%) |
{{ &shop }} | 商店 ID |
{{ &goods-id }} | 当前发放的实际商品 ID;随机商品、多 id 场景会取展开后的真实值 |
{{ &slot-key }} | 商店内的原始槽位 key |
{{ &limit }} / {{ &limit_remaining }} | 购买后剩余限额 |
{{ sender }} | 购买者名称 |
示例
actions: |-
tell color inline "&7购买了 {{ &amount }} &f{{ &display-name }}"
tell inline "共消费 {{ &price }}"
actions: |-
command inline "lp user {{ sender }} permission settemp vip.member true 7d" as console
tell color inline "&a&l恭喜! &f你已获得 &e7天VIP &f权限"
title inline "&6&lVIP 激活" inline "&7有效期 7 天" 20 40 20
tags 标签
tags 是一个字符串数组,用于商品搜索功能。玩家在商店中使用搜索时,会匹配商品的 tags。
tags:
- 武器
- 钻石
- 锻造
你也可以使用行内写法:
tags: [VIP, 权限, 热门]