检测挂机玩家
基于头部旋转检测玩家闲置状态——简单、准确且快速。旨在作为数据包和服务端操作员的依赖项。
如果没有附加组件(更好的性能),本模组功能有限,因此你可能还需要下载其中一个附加组件。
附加组件
核心功能
- 3 分钟后将玩家标记为
afk
- 基于头部旋转进行检测,比基于位置更准确
- 性能显著优于其他替代方案
- 模块化设计(参见上方的附加组件)
要配置变为挂机状态所需的时间,请使用以下命令。默认设置为 3600(即 3 分钟)。
/scoreboard players set .threshold afk.settings NUMBER_OF_TICKS
若要启用使用 /trigger afk 的玩家,请使用以下命令。除非管理员启用,否则不允许玩家手动进入挂机状态。
/scoreboard players enable PLAYER afk
性能
常见的 AFK 检测方法会检查 X/Y/Z 坐标、物品栏变化和方块交互——通常在每个游戏刻(tick)都进行检查。相反,此数据包每 1.5 秒仅对每位玩家进行一次头部旋转 NBT 检查,从而产生显著减少的计算量,相比其他方案有时可减少两个数量级。
头部旋转方法还消除了由实体交互(玩家攻击、爆炸等)以及反挂机自动化装置(如水渠)引起的误触发。
API
提供了两个函数标签:
afk:away - 玩家进入挂机状态时执行,以该玩家为执行者
afk:back - 玩家返回在线状态时执行,以该玩家为执行者
GitHub 上提供了更多文档,包括所有稳定的计分板目标及其使用方法。
示例实现:
kick-afk-players/data/afk/tags/functions/away.json
{ "values": ["afk_kick:kick"] }
kick-afk-players/data/afk_kick/functions/kick.mcfunction
kick @s AFK
Detect AFK Players
Detects player inactivity based on head rotation - simple, accurate, and fast. Intended as a dependency for datapacks and server operators.
This doesn't do much without add-ons (better performance), so you'll probably want to download one of those too.
Add-ons
- Pause Day Cycle - Pauses time when all players are AFK
- AFK Sleep - Allows sleeping when players are AFK, and handles dimensions + updates correctly unlike alternatives
- AFK Dim Names - Player names are dimmed when AFK
- AFK Message - Chat notifications for player status
- AFK Sit - Players sit down when they're AFK
Core Functionality
- Tags players as
afk after 3 minutes
- Detection based on head rotation, more accurate than position
- Significantly better performance than alternatives
- Modular (see above for add-ons)
To configure how long it takes to become AFK, use the command below.
By default, this is set to 3600 (which is 3 minutes).
/scoreboard players set .threshold afk.settings NUMBER_OF_TICKS
To enable players using /trigger afk, use the following command. No players are allowed to become AFK manually unless enabled by an admin.
/scoreboard players enable PLAYER afk
Performance
Common AFK detection methods check X/Y/Z, inventory changes, and block interactions - often on every tick. Instead, this data pack does a single head rotation NBT check per player every 1.5 seconds, resulting in a significantly less computation as compared to alternatives, sometimes by up to two orders of magnitude.
The head rotation method also eliminates false triggers from entity interactions (players attacking, explosions, etc) and anti-AFK automations such as water streams.
API
Two function tags are provided:
afk:away - Executed as player on AFK
afk:back - Executed as player on return
Additional documentation is provided on GitHub, such as all the stable scoreboard objectives and how to use them.
Example implementation:
kick-afk-players/data/afk/tags/functions/away.json
{ "values": ["afk_kick:kick"] }
kick-afk-players/data/afk_kick/functions/kick.mcfunction
kick @s AFK
评论 0
登录后参与评分
还没有评论,来抢沙发吧