Skip to content

内置动作

动作修改物品或对玩家/世界产生副作用。语法统一为 目标.动作类别.方法(参数)

yaml
execute: |
  # 链式调用(推荐)
  装备.lore.attr("攻击力", "+10")
  装备.name.prefix("&6[强化] ")
  装备.enchant.add("SHARPNESS", 5)

  # 不带目标,作用于当前 with 块 / target
  lore.append("&7新的一行")

  # 独立动作(不绑定物品)
  effect.message("&a操作成功")
  money.take(1000)
  slot.set("output", @input)

目标物品的三种来源

yaml
# 1. with 块自动注入(最简洁,自动写回)
with @input {
  装备.lore.attr("攻击力", "+10")
}

# 2. 手动赋值
装备 = @input
装备.lore.attr("攻击力", "+10")
slot.set("input", 装备)    # 必须手动写回

# 3. 直接用槽位引用
@input.lore.attr("攻击力", "+10")

装备 不是关键字,只是约定俗成的变量名,也可以叫 武器 = @inputitem = @input

参数格式规则

绝大多数动作只支持位置参数,严格按顺序传入:

yaml
装备.lore.attr("攻击力", "+10")            # ✓
装备.lore.setCounter("强化次数", 3, 10)    # ✓
装备.enchant.add("SHARPNESS", 5)           # ✓

唯一支持命名参数的是 lore.replace,用 = 号(不是 :):

yaml
装备.lore.replace(find="强化等级", old="{旧}", new="{新}")     # ✓
装备.lore.replace(find: "强化等级", old: "{旧}")              # ✗ 冒号不支持

拼接运算符和变量:

yaml
增加量 = 10
装备.lore.attr("攻击力", "+" + 增加量)                # 拼成 "+10"
装备.lore.setAttr("攻击力", "+", 增加量)              # 或用 setAttr 分开传

动作分类

页面覆盖
Lore 动作lore.replace / .append / .insert / .delete / .clear / .setLine / .attr / .setAttr / .setCounter / .setValue / .insertAfter / .sort / .copy / .move / .random_replace
Name / NBT 动作name.set / .prefix / .suffixnbt.set / .add / .remove;颜色码速查
物品 / 经济动作item.give / .take / .clear / .setTypeamount.setenchant.add / .removedurability.set / .repairmoney.* / points.*
效果动作effect.message / .sound / .title / .actionbar / .particle / .potion / .command / .console / .close / .refresh / .open
槽位 / GUI / 延迟动作slot.set / .clear / .take / .lock / .unlockgui.lock / .unlockdelay 动画模式
其他各插件集成动作的快速汇总(LyShop 货币、仓库、CraftX 等 — 多数通过函数调用而非动作)

链式调用支持表

所有列在下表的动作都支持 变量.类型.方法(参数) 链式形式(例如 装备.lore.append(...)):

分类动作
LorereplaceappendinsertdeleteclearsetLineattrsetAttrsetCountersetValueinsertAfterrandom_replacesortcopymove
Namesetprefixsuffix
NBTsetaddremove
附魔addremove
物品setTypeamount.set
耐久setrepair

独立动作(没有目标物品,如 effect.*money.*slot.*gui.*item.giveitem.takedelay不走链式,直接调用。

下一步:Lore 动作

TQ Minecraft Server Plugin Docs