
一个 Skript 插件,让你可以将行为视为值,从而大幅减少样板代码。它提供了:
- Lambda(匿名函数): 可保存在变量中、传递并在稍后运行的小型函数。支持闭包、默认参数和管道操作。
- 谓词(Predicates): 可复用的“是/否”测试,可与
all、any或none组合使用,或统计通过的数量。 - 列表操作: 无需手动编写循环即可进行映射(Map)、归约(Reduce)、扫描(Scan)、合并(Zip)、排序、最高/最低值查找以及分页。
- 自动清理的监听器: 作用域限定于单个玩家或命令的临时事件监听器,具备计时器、触发次数限制和生命周期回调。它们会在完成后自行停止。
- 异步执行: 在后台线程运行 Lambda,使用 Future 机制,在不冻结服务器的情况下等待事件或结果,并监控值或条件的变化。
链接
示例:同一任务,两种写法
任务:告诉玩家在 30 秒内挖掘 10 个石头。如果完成则给予钻石,未完成则提示“太慢了”。
不使用 skLambda
on break of stone:
if {challenge::%player%} is not set:
stop
add 1 to {challenge::progress::%player%}
if {challenge::progress::%player%} >= 10:
send "you did it!" to player
give 1 diamond to player
delete {challenge::%player%}
delete {challenge::progress::%player%}
command /challenge:
trigger:
set {challenge::%player%} to true
set {challenge::progress::%player%} to 0
send "mine 10 stone in 30s" to player
wait 30 seconds
if {challenge::%player%} is set:
send "too slow" to player
delete {challenge::%player%}
delete {challenge::progress::%player%}
需要手动处理很多事情:一个针对每个玩家都会运行的全局 on break of stone 事件、一个标志变量、一个计数器变量、用于超时的独立 wait 语句,以及到处分布的 delete 行用于清理。
使用 skLambda
command /challenge:
trigger:
send "mine 10 stone in 30s" to player
listen for block break where event-block is stone:
countdown: 30 seconds
triggers: 10
every 1 second:
send action bar "%remaining triggers% left — %remaining countdown%" to event-player
on completion:
send "you did it!" to event-player
give 1 diamond to event-player
on timeout:
send "too slow!" to event-player
就是这样。该监听器属于当前这个命令的执行上下文。计数器、计时器和实时的动作栏显示都已内置,当任务完成或超时时,它会自行清理。
不止于监听器
保存一个测试条件并在列表上运行。谓词可以与 Skript 自带的过滤器配合使用,而列表操作可以跳过循环:
# 仅保留处于空闲状态 (AFK) 的玩家
set {_afk} to lambda (p: player): {_p}'s idle time > 5 minutes
set {_idle::*} to all players where [{_afk} passes for input]
# 使用 Lambda 为每个玩家评分,获取获胜者
set {_score} to lambda (p: player) -> number:
return {_p}'s level
set {_mvp} to highest of all players by {_score}
1.3.0 版本新增功能:你可以暂停触发器并等待,而不会冻结服务器:
command /confirm:
trigger:
send "type 'yes' in chat within 15s to confirm." to player
wait for next chat where player is sender within 15 seconds:
if message is "yes":
send "confirmed!" to player
on timeout:
send "cancelled — no reply." to player
当玩家聊天时,触发器会从断点处继续执行,而服务器在此期间一直保持响应。你也可以 wait for 后台作业(调用 Lambda 产生的 future)或 watch 值或条件,仅在发生变化时做出反应。
完整指南和数十个可运行的示例请查看 wiki。
要求
许可证
统计数据
skLambda 使用 bStats 收集匿名使用统计数据。你可以在 plugins/bStats/config.yml 中选择退出。
备注
如果你遇到任何问题,请在 Discord 上联系我 eult,或加入 discord server

A Skript addon that lets you treat behavior as a value, and cut a lot of boilerplate while you're at it. It adds:
- Lambdas: Small functions you save in a variable, pass around, and run later. They support closures, default parameters, and piping.
- Predicates: Reusable yes/no tests you can combine with all, any, or none, or count how many pass.
- List operations: Map, reduce, scan, zip, sort, highest/lowest, and paging, without writing the loops yourself.
- Self-cleaning listeners: Temporary event listeners scoped to one player or command, with a timer, a hit count, and lifecycle callbacks. They stop themselves.
- Async: Run a lambda off the main thread with futures,
wait foran event or result without freezing the server, andwatcha value or condition.
Links
Example: same task, two ways
The task: tell the player to mine 10 stone in 30 seconds. Give a diamond if they finish, say "too slow" if they don't.
Without skLambda
on break of stone:
if {challenge::%player%} is not set:
stop
add 1 to {challenge::progress::%player%}
if {challenge::progress::%player%} >= 10:
send "you did it!" to player
give 1 diamond to player
delete {challenge::%player%}
delete {challenge::progress::%player%}
command /challenge:
trigger:
set {challenge::%player%} to true
set {challenge::progress::%player%} to 0
send "mine 10 stone in 30s" to player
wait 30 seconds
if {challenge::%player%} is set:
send "too slow" to player
delete {challenge::%player%}
delete {challenge::progress::%player%}
Lots to do by hand: a global on break of stone that runs for every player, a flag variable, a counter variable, a separate wait for the timeout, and delete lines everywhere to clean up.
With skLambda
command /challenge:
trigger:
send "mine 10 stone in 30s" to player
listen for block break where event-block is stone:
countdown: 30 seconds
triggers: 10
every 1 second:
send action bar "%remaining triggers% left — %remaining countdown%" to event-player
on completion:
send "you did it!" to event-player
give 1 diamond to event-player
on timeout:
send "too slow!" to event-player
That's it. The listener belongs to this one command run. The counter, the timer, and the live action-bar readout are built in, and when it finishes or times out, it cleans up by itself.
More than listeners
Save a test and run it over a list. Predicates pair with Skript's own filter, and list operations skip the loop:
# keep only the players who are AFK
set {_afk} to lambda (p: player): {_p}'s idle time > 5 minutes
set {_idle::*} to all players where [{_afk} passes for input]
# score every player with a lambda, grab the winner
set {_score} to lambda (p: player) -> number:
return {_p}'s level
set {_mvp} to highest of all players by {_score}
New in 1.3.0, you can pause a trigger and wait without freezing the server:
command /confirm:
trigger:
send "type 'yes' in chat within 15s to confirm." to player
wait for next chat where player is sender within 15 seconds:
if message is "yes":
send "confirmed!" to player
on timeout:
send "cancelled — no reply." to player
The trigger picks up right where it left off when the player chats, and the server keeps ticking the whole time. You can also wait for a background job (future of calling lambda ...) or watch a value or condition and react only when it changes.
Full guides and dozens of runnable examples are on the wiki.
Requirements
License
Stats
skLambda uses bStats for anonymous usage stats. You can opt out in plugins/bStats/config.yml.
NOTES
if you experience any problems, let me know on discord eult, discord server
下载 skLambda
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 skLambda
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 skLambda
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 skLambda
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 skLambda
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 skLambda
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 skLambda
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 skLambda
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
skLambda 1.6.0
支持: Paper 1.21.1+ · Skript 2.15+ 想要更多详细信息?wiki: New-Features
添加了一个新的命令模块,用于控制玩家按下 / 时看到的命令列表。
show only commands %strings% [where <condition>]:将列表限制为指定的命令。每当发送玩家的命令列表时,都会对每个玩家检查该条件,因此权限组在加载时即可生效。规则会叠加,匹配不到任何规则的玩家将看不到任何命令。hide commands where %object% passes:隐藏所有通过指定 lambda 表达式的命令。该 lambda 表达式依次接收命令标签和玩家作为参数。hide commands %strings% from %players% / show commands %strings% to %players%:针对特定玩家隐藏命令,直到执行对应的显示命令为止。reset command visibility [for %players%]:清除所有规则和隐藏设置,或仅清除指定玩家的隐藏设置。
示例
on load:
show only commands "help", "msg" and "tpa" where player has permission "group.default"
show only commands "ban", "kick" and "mute" where player has permission "group.mod"
set {_namespaced} to lambda (cmd: text): {_cmd} contains ":"
hide commands where {_namespaced} passes
on damage of player:
hide commands "spawn" and "home" from victim
wait 10 seconds
show commands "spawn" and "home" to victim
command /resetcommands:
trigger:
reset command visibility
玩家的命令列表会立即更新,无需重新加入服务器。当创建这些规则和隐藏设置的脚本被重载时,相关规则和隐藏设置会被移除。隐藏功能仅改变玩家可见的内容,手动输入的命令仍会正常执行。如需关闭此模块,请在 config.yml 中设置 commands: false。
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
插件
PacketEvents 是一款专为 Minecraft Java 版打造的协议库,旨在简化数据包的处理与传输。
插件
ExyliaPlugins 的库。
插件
通过对话框或铁砧界面帮助你的 Anthme
插件
重新定义服务器上的生物运输方式。使用高度可定制的口袋道具,安全地捕获、存储和释放任何实体。
插件
为基于 Spigot/Paper/Folia 的服务器添加对 Vivecraft 的支持
插件
用于绘制游戏内地图或在浏览器中随探索实时进行地图绘制的实时地图。





评论 0
登录后参与评分
还没有评论,来抢沙发吧