集成 / 冷却 / 调试函数
玩家与 PAPI
| 函数 | 参数 | 返回 | 说明 |
|---|---|---|---|
hasPermission(node) | String | Boolean | 检查权限节点 |
isOp() | — | Boolean | 是否 OP |
papi(placeholder) | String | String | 解析单个 PAPI 变量(无需 % 包裹) |
papi_parse(text) | String | String | 解析整段文本中的所有 %xxx% 变量 |
yaml
是VIP = hasPermission("vip.enhance")
金币 = papi("vault_eco_balance")
欢迎 = papi_parse("欢迎 %player_name%,等级 %player_level%")冷却
| 函数 | 参数 | 返回 | 说明 |
|---|---|---|---|
cooldown(key) | String | Integer | 剩余冷却秒数(0 = 已就绪) |
cooldown(key, seconds) | String, Integer | 0 | 设置冷却 |
cooldown_ready(key) | String | Boolean | 冷却是否结束 |
cooldown_set(key, seconds) | String, Integer | Boolean | 设置冷却 |
cooldown_clear(key) | String | Boolean | 清除冷却 |
yaml
conditions: |
require cooldown_ready("enhance") : "&c强化冷却中,剩余{cooldown('enhance')}秒"
execute: |
cooldown_set("enhance", 60) # 60 秒冷却冷却 key 是按玩家隔离的,不同玩家互不干扰。
CraftX 永久变量
存储在 CraftX 数据库中的玩家永久变量(跨登录保留)。
| 函数 | 参数 | 返回 | 说明 |
|---|---|---|---|
cx_get(var) | String | Any | 当前玩家变量 |
cx_get(player, var) | String×2 | Any | 指定玩家变量 |
cx_set(var, value) | String, Any | Any | 设置 |
cx_set(player, var, value) | String×2, Any | Any | 设置指定玩家 |
cx_add(var, amount) | String, Number | Any | 增加 |
cx_take(var, amount) | String, Number | Any | 减少 |
cx_has(var, amount) | String, Number | Boolean | 检查是否 ≥ |
cx_remove(var) | String | null | 删除 |
cx_count(var) | String | Integer | 统计数量 |
yaml
强化次数 = cx_get("enhance_count")
cx_add("enhance_count", 1)
cx_set("last_enhance", datetime())CraftX 临时变量
支持过期时间的临时变量。
| 函数 | 参数 | 返回 | 说明 |
|---|---|---|---|
cxt_get(var) | String | Any | 读取 |
cxt_set(var, value) | String, Any | Any | 设置(无过期) |
cxt_set(var, value, expire) | String, Any, Long | Any | 设置并指定过期毫秒 |
cxt_add(var, amount) / cxt_take(var, amount) | String, Number | Any | 增加 / 减少 |
cxt_has(var, amount) | String, Number | Boolean | 检查是否 ≥ |
cxt_remove(var) | String | null | 删除 |
cxt_expire(var) | String | Long | 获取过期时间戳 |
cxt_expire(var, expire) | String, Long | null | 设置过期时间 |
yaml
# 每日次数限制
cxt_set("daily_enhance", 0, 86400000) # 24 小时后过期
今日次数 = cxt_get("daily_enhance")LyShop 货币
| 函数 | 参数 | 返回 | 说明 |
|---|---|---|---|
lshop_get(currency) | String | Long | 当前玩家余额 |
lshop_get(player, currency) | String×2 | Long | 指定玩家余额 |
lshop_has(currency, amount) | String, Number | Boolean | 是否足够 |
lshop_take(currency, amount) | String, Number | Boolean | 扣除 |
lshop_give(currency, amount) | String, Number | Boolean | 发放 |
lshop_exists(currency) | String | Boolean | 货币是否存在 |
yaml
conditions: |
require lshop_has("绑定金币", 1000) : "&c绑定金币不足"
execute: |
lshop_take("绑定金币", 1000)仓库(Warehouse)
| 函数 | 参数 | 返回 | 说明 |
|---|---|---|---|
wh_give(item, amount) | Item, Integer | Boolean | 发放到默认仓库 |
wh_give(item, amount, type) | Item, Integer, String | Boolean | 发放到指定仓库 |
wh_count(item) | Item | Long | 统计所有仓库数量 |
wh_count(item, type) | Item, String | Long | 统计指定仓库数量 |
wh_take(item, amount) | Item, Integer | Integer | 扣除(返回未扣数量) |
wh_has(item, amount) | Item, Integer | Boolean | 是否足够 |
type 参数可选值:"soulringx" / "srx"、"lywarehouse" / "lw"、"inventory" / "inv"、"all"。
yaml
钻石数 = wh_count(item.create("DIAMOND"), "all")
wh_give(@output, 1, "soulringx")Vault 物品存储
把物品暂存到数据库,返回一个 ID 用于跨会话 / 跨服取回。
| 函数 | 参数 | 返回 | 说明 |
|---|---|---|---|
vault.store(@item) | 槽位/Item | String | 存储,返回 ID |
vault.get(id) | String | ItemStack | 按 ID 取回 |
vault.remove(id) | String | Boolean | 删除 |
vault.exists(id) | String | Boolean | 是否存在 |
yaml
execute: |
物品ID = vault.store(@input)
# ... 通过数据库 / Redis 传递 ID ...
恢复物品 = vault.get(物品ID)配方
| 函数 | 参数 | 返回 | 说明 |
|---|---|---|---|
match_recipe(@recipes, mats...) | recipes, Item... | Recipe / null | 根据配置中的 recipes 字段匹配,返回匹配的配方对象或 null |
yaml
execute: |
匹配 = match_recipe(@recipes, @m1, @m2, @m3, @m4, @m5, @m6, @m7, @m8, @m9)
if 匹配 != null {
配方名 = 匹配.id
成品 = 匹配.result
slot.set("output", 成品)
}配方字段的完整写法见 配方系统。
调试
| 函数 | 参数 | 返回 | 说明 |
|---|---|---|---|
log(msg, ...) | Any... | null | 输出到服务端控制台 |
debug(value) | Any | Any | 输出详情到玩家和控制台,返回原值 |
yaml
execute: |
log("开始执行,等级:", 当前等级)
debug(@input) # 把物品详情发给玩家和控制台
# 因为返回原值,可以包在表达式里
总和 = sum(debug(a), debug(b), debug(c))