这是 Unplugged AFK 的 功能尚不完整 的 Paper 移植版,该模组由 Sakura Ryoko 为 Fabric 开发,采用 LGPL3 或更高版本许可证发布。
一条命令即可断开你的客户端连接,并留下一个未插线的玩家站在你原来的位置,在农场里替你占位,直到你声明的时间耗尽。
重要提示: 未插线的玩家是你自己的可交互、可击杀版本。如果它死亡,其物品栏会正常掉落,当你重新加入时会出现死亡画面。
警告: 未插线的玩家加入时绕过了登录步骤中权限插件挂钩的流程。LuckPerms 得到直接支持,因此安装后,未插线玩家的权限解析与你完全一致。其他所有权限插件都需要专门添加支持,在此之前,未插线玩家仅回退到操作者状态和插件默认值,因此通过群组授予的 AFK 踢出绕过对其无效。
特性
- 绿色环保: 关闭电脑,让未插线的玩家替你挂机
- 物品栏继承: 未插线的玩家初始拥有你的物品栏,并在返回时交还收集到的所有物品
- 可配置限制: 操作者可设置最大持续时间以及全局允许存在的未插线玩家数量上限
- 管理员控制: 提供检查谁处于未插线状态以及调试插件行为的命令
- 占位符感知: 安装了 PlaceholderAPI 或 MiniPlaceholders 时,记分板、标签页列表和聊天插件可以显示谁处于未插线状态以及持续了多久
- CMI 兼容: 安装了 CMI 时,未插线的玩家在出现时即被标记为 AFK,且永远不会因 AFK 而被踢出
- 代理感知: 在 Velocity 代理后方,断开连接会使你脱离整个网络,重新连接会将你放回未插线玩家所在的服务器,且服务器列表仍将其计入
计划中
- 绕过最大时长: 赋予员工或 VIP 玩家超过配置最大时长进行未插线操作的权限
- 绕过上限: 即使达到上限,也允许员工或 VIP 玩家进行未插线操作
- 可配置消息: 将插件的聊天消息移至配置文件
- 历史数据: 将记录持久化到磁盘,以便员工审查玩家使用插件的情况
- 服务器重启时重生未插线玩家: 在后端重启时自动恢复它们
- 更多管理员命令: 代替在线玩家执行未插线操作、对离线玩家执行未插线操作等
依赖要求
两半部分都深入宿主自身的内部结构:后端是 Minecraft,代理是 Velocity。每个 JAR 都是针对特定的 Minecraft 版本或 Velocity 分支构建的,并以对应名称命名,请为每个宿主提供匹配的 JAR 文件。此表之外的情况尽最大努力支持,并在启动时记录日志。
| JAR |
运行于 |
Java |
unplugged-afk-1.21.11-<version>.jar |
Paper 1.21.11 或其分支 |
21 或更高 |
unplugged-afk-26.1.2-<version>.jar |
Paper 26.1.2 或其分支 |
25 或更高 |
unplugged-afk-26.2-<version>.jar |
Paper 26.2 或其分支 |
25 或更高 |
unplugged-afk-velocity-3.5.1-<version>.jar |
Velocity 3.5 |
21 或更高 |
unplugged-afk-velocity-4.0.0-<version>.jar |
Velocity 4 |
25 或更高 |
安装
将适用于你服务器 Minecraft 版本的后端 JAR 放入每个后端的 plugins/ 目录中。如果使用 Velocity 代理,还需将适用于你 Velocity 版本的代理 JAR 放入代理的 plugins/ 目录中。从同一个发布包安装两者;不支持混合版本。重启各服务器。
命令
| Command |
Description |
Permission |
/unplug <duration> <reason> |
断开你的连接,并留下一个未插线的玩家在你的位置待 duration 分钟 |
unplugged-afk.unplug |
/unplugged info <player> |
显示 player 的未插线详细信息 |
unplugged-afk.admin.info |
/unplugged list |
列出所有未插线玩家,以及已使用的上限槽位数 |
unplugged-afk.admin.list |
/unplugged debug spawn-fake <duration> [reason] |
生成一个带有随机 UUID 和名称的临时未插线玩家。需要 debug: true |
unplugged-afk.admin.debug |
配置
后端
plugins/unplugged-afk/config.yml,在每个后端上。
| 键 |
描述 |
默认值 |
最小值 |
最大值 |
version |
文件结构版本。插件会自动升级此值,请勿修改 |
1 |
|
|
debug |
启用调试功能。详见 调试模式 |
false |
|
|
maxUnpluggedPlayers |
允许同时处于离线状态的玩家数量上限 |
16 |
1 |
|
maxDurationMins |
玩家离线的最长持续时间(分钟) |
480 |
1 |
|
link.host |
代理服务器的地址 |
127.0.0.1 |
|
|
link.port |
代理监听的端口号 |
25580 |
1 |
65535 |
link.secret |
从代理配置中复制而来 |
|
|
|
link.serverName |
后端服务器的名称,必须与 velocity.toml 中的拼写完全一致 |
|
|
|
messages.label |
%unplugged-afk_label% 变量在玩家离线时显示的内容 |
? |
|
|
超出范围的数值将被截断并重置为默认值,同时在控制台中输出警告信息。
在代理服务器后方时,link.secret 和 link.serverName 没有可用的默认值,插件会在两者均未设置的情况下拒绝启用。
代理配置
位于代理端的 plugins/unplugged-afk/config.yml 文件。
| 键 |
描述 |
默认值 |
最小值 |
最大值 |
version |
文件结构版本。插件会自动升级此值,请勿修改 |
1 |
|
|
debug |
将链接、存在状态和中继活动记录到控制台 |
false |
|
|
link.host |
监听地址。如果后端在其他机器上,请放宽此限制 |
127.0.0.1 |
|
|
link.port |
监听的端口号 |
25580 |
1 |
65535 |
link.secret |
首次启动时生成。将其复制到每个后端服务器中 |
|
|
|
messages.label |
<unplugged-afk_label> 标签在玩家离线时显示的内容 |
? |
|
|
超出范围的数值将被截断并重置为默认值,同时在控制台中输出警告信息。
警告: 链接端口是代理与其后端之间的内部通道,绝非面向玩家的端口。如果你将 link.host 的范围扩大到 127.0.0.1 之外,请在防火墙中将端口限制为你的后端服务器使用。开放的端口会被服务器扫描器发现。
权限
| 节点 |
授予权限 |
默认角色 |
unplugged-afk.unplug |
/unplug |
所有玩家 |
unplugged-afk.admin |
下方所有的管理员节点 |
操作员 |
unplugged-afk.admin.info |
/unplugged info |
操作员 |
unplugged-afk.admin.list |
/unplugged list |
操作员 |
unplugged-afk.admin.debug |
/unplugged debug 及其子命令 |
操作员 |
占位符
PlaceholderAPI
安装 PlaceholderAPI 后,后端插件会以标识符 unplugged-afk 注册一个扩展。
| 占位符 |
返回值 |
%unplugged-afk_is_unplugged% |
true 或 false |
%unplugged-afk_duration_mins% |
玩家请求的窗口时长(分钟) |
%unplugged-afk_reason% |
传递给 /unplug 的原因 |
%unplugged-afk_started% |
距离开始离线的时间,例如 2 hour(s) 5 minute(s) |
%unplugged-afk_expires% |
剩余时间,格式同上 |
%unplugged-afk_remaining_mins% |
剩余时间,以纯数字表示的分钟数 |
%unplugged-afk_is_fake% |
对于通过 /unplugged debug spawn-fake 生成的离线玩家,返回 true |
%unplugged-afk_label% |
配置的 messages.label 值,默认为 ? |
%unplugged-afk_count% |
当前服务器持有的离线玩家数量,与 /unplugged list 总数匹配 |
除 %unplugged-afk_count% 外,所有占位符均描述单个玩家的状态;如果该玩家未离线,则渲染为空字符串。%unplugged-afk_is_unplugged% 在这种情况下会渲染为 false。
MiniPlaceholders
安装 MiniPlaceholders 后,两个 JAR 包都会注册同名的扩展。MiniMessage 使用标签 <unplugged-afk_is_unplugged> 而非 %unplugged-afk_is_unplugged%。
安装在后端服务器上时,这些标签针对该服务器生效;安装在代理端时,它们针对整个网络生效。其中有两个标签在两端有所不同:
| 标签 |
在后端服务器上 |
在代理端 |
<unplugged-afk_count> |
当前服务器持有的离线玩家数量 |
整个网络持有的离线玩家总数 |
<unplugged-afk_server> |
未注册 |
离线玩家所在的服务器名称 |
其余标签的含义如上所述,且在两端渲染结果相同。
代理支持
Velocity
在 Velocity 后端,/unplug 命令需要断开你与整个网络的连接,而不仅仅是当前所在的单个后端;重新连接时,则需要将你送回持有你离线状态的玩家长所在的后端。为此,代理服务器上必须安装配套的 JAR 文件才能正常工作。
支持的 Velocity 版本列于 Requirements(需求)部分。其他版本的兼容性为尽力支持,若启动时无法解析所需的内部接口,配套程序会在日志中记录一条错误信息。
调试模式
此处所有功能均受 debug 配置标志控制,默认处于关闭状态。
/unplugged debug spawn-fake 命令将变为可用。它会生成一个临时的离线玩家,拥有随机的 UUID 和名称。
在代理环境下,该命令要求代理可达,这与 /unplug 的要求相同。
- 每次执行
/unplug 都会在 plugins/unplugged-afk/dumps/ 目录下写入一个文本文件,其中包含会话详情以及玩家的完整快照(包括物品栏和末影箱)。
代理服务器拥有独立的 debug 标志,可独立于后端的设置进行配置。它用于控制那些对调试有用的冗长控制台日志输出。
致谢
衷心感谢 Sakura Ryoko 开发的 Unplugged AFK,本插件正是基于该模组移植而来。如果没有他们的工作,本插件将无从谈起。
A feature-incomplete Paper port of Unplugged AFK, the Fabric mod by
Sakura Ryoko, published under the LGPL3-or-later license.
One command disconnects your client and leaves an unplugged player standing where you were, holding your spot at a farm
until the time you declared runs out.
IMPORTANT: The unplugged player is an interactable, killable version of you. If it dies, its inventory drops as normal and you
get the death screen on rejoining.
WARNING: The unplugged player joins without the login step permission plugins hook into. LuckPerms is supported directly, so
with it installed the unplugged player resolves permissions exactly as you do. Every other permission plugin needs
support added for it specifically, and until then the unplugged player falls back to operator status and plugin
defaults alone, so an AFK-kick bypass granted through a group will not apply to it.
Features
- Go green: turn off your computer and leave your unplugged player to AFK for you
- Inventory carries over: the unplugged player starts with your inventory, and hands back whatever it collected
- Configurable limits: operators set the maximum duration and a global cap on how many unplugged players can exist
- Admin control: commands to inspect who is unplugged, and to debug the plugin's behaviour
- Placeholder aware: with PlaceholderAPI or MiniPlaceholders installed, scoreboards, tab lists and chat plugins can
show who is unplugged and for how long
- CMI aware: with CMI installed, the unplugged player is marked AFK as soon as it appears and is never AFK-kicked
- Proxy aware: behind Velocity, unplugging disconnects you from the whole network, returning puts you back on the
server your unplugged player is on, and the server list still counts it
Planned
- Bypass max duration: a permission letting staff or VIPs unplug for longer than the configured maximum
- Bypass cap: a permission letting staff or VIPs unplug even once the cap is reached
- Configurable messages: move the plugin's chat messages into the config
- Historical data: persist records to disk so staff can review how players have used the plugin
- Re-spawn unplugged players on server reboot: bring them back automatically when a backend restarts
- More admin commands: unplug an online player on their behalf, unplug an offline player, and similar
Requirements
Both halves reach into their host's own internals, Minecraft's on the backend and Velocity's on the proxy. Each JAR is
built against one Minecraft version or one Velocity line and named for it, so give each host the JAR that matches.
Anything outside this table is best-effort and logged on startup.
| JAR |
Runs on |
Java |
unplugged-afk-1.21.11-<version>.jar |
Paper 1.21.11, or a fork |
21 or newer |
unplugged-afk-26.1.2-<version>.jar |
Paper 26.1.2, or a fork |
25 or newer |
unplugged-afk-26.2-<version>.jar |
Paper 26.2, or a fork |
25 or newer |
unplugged-afk-velocity-3.5.1-<version>.jar |
Velocity 3.5 |
21 or newer |
unplugged-afk-velocity-4.0.0-<version>.jar |
Velocity 4 |
25 or newer |
Installation
Drop the backend JAR for your server's Minecraft version into every backend's plugins/ directory. Behind a Velocity
proxy, also drop the proxy JAR for your Velocity line into the proxy's plugins/ directory. Install both from the same
release; mixed versions are not supported. Restart each server.
Commands
| Command |
Description |
Permission |
/unplug <duration> <reason> |
Disconnects you and leaves an unplugged player in your place for duration minutes |
unplugged-afk.unplug |
/unplugged info <player> |
Shows the unplugged details for player |
unplugged-afk.admin.info |
/unplugged list |
Lists every unplugged player, and how many slots of the cap are in use |
unplugged-afk.admin.list |
/unplugged debug spawn-fake <duration> [reason] |
Spawns a throwaway unplugged player with a random UUID and name. Requires debug: true |
unplugged-afk.admin.debug |
Configuration
Backend
plugins/unplugged-afk/config.yml, on every backend.
| Key |
Description |
Default |
Minimum |
Maximum |
version |
The file's shape. The plugin upgrades it, do not edit |
1 |
|
|
debug |
Enables debug functionality. See Debug Mode |
false |
|
|
maxUnpluggedPlayers |
How many unplugged players may exist at the same time |
16 |
1 |
|
maxDurationMins |
The longest a player may unplug for, in minutes |
480 |
1 |
|
link.host |
The proxy's address |
127.0.0.1 |
|
|
link.port |
The port the proxy listens on |
25580 |
1 |
65535 |
link.secret |
Copied from the proxy's config |
|
|
|
link.serverName |
This backend's name, exactly as velocity.toml spells it |
|
|
|
messages.label |
What %unplugged-afk_label% shows for an unplugged player |
? |
|
|
Out-of-range values are clamped back to their default, with a warning in the console.
Behind a proxy, link.secret and link.serverName have no usable default, and the plugin refuses to enable until both
are set.
Proxy
plugins/unplugged-afk/config.yml, on the proxy.
| Key |
Description |
Default |
Minimum |
Maximum |
version |
The file's shape. The plugin upgrades it, do not edit |
1 |
|
|
debug |
Logs link, presence and relay activity to the console |
false |
|
|
link.host |
The address to listen on. Widen it for backends on other machines |
127.0.0.1 |
|
|
link.port |
The port to listen on |
25580 |
1 |
65535 |
link.secret |
Generated on first start. Copy it into every backend |
|
|
|
messages.label |
What <unplugged-afk_label> shows for an unplugged player |
? |
|
|
Out-of-range values are clamped back to their default, with a warning in the console.
WARNING: The link port is an internal channel between the proxy and its backends, never a player-facing one. If you widen
link.host past 127.0.0.1, restrict the port to your backends at the firewall. An open one gets found by server
scanners.
Permissions
| Node |
Grants |
Default |
unplugged-afk.unplug |
/unplug |
Everyone |
unplugged-afk.admin |
Every admin node below |
Operators |
unplugged-afk.admin.info |
/unplugged info |
Operators |
unplugged-afk.admin.list |
/unplugged list |
Operators |
unplugged-afk.admin.debug |
/unplugged debug and its subcommands |
Operators |
Placeholders
PlaceholderAPI
With PlaceholderAPI installed, the backend plugin registers an
expansion under the identifier unplugged-afk.
| Placeholder |
Gives |
%unplugged-afk_is_unplugged% |
true or false |
%unplugged-afk_duration_mins% |
The window the player asked for, in minutes |
%unplugged-afk_reason% |
The reason given to /unplug |
%unplugged-afk_started% |
How long ago they unplugged, such as 2 hour(s) 5 minute(s) |
%unplugged-afk_expires% |
How long is left, in the same form |
%unplugged-afk_remaining_mins% |
How long is left, as a plain number of minutes |
%unplugged-afk_is_fake% |
true for an unplugged player from /unplugged debug spawn-fake |
%unplugged-afk_label% |
The configured messages.label, ? by default |
%unplugged-afk_count% |
How many this server holds, matching the /unplugged list total |
Every placeholder except %unplugged-afk_count% describes one player and renders empty when that player is not
unplugged. %unplugged-afk_is_unplugged% renders false instead.
MiniPlaceholders
With MiniPlaceholders installed, both JARs register an expansion under
the same name. MiniMessage spells the tags <unplugged-afk_is_unplugged> rather than %unplugged-afk_is_unplugged%.
Installed on a backend, the tags answer for that server. Installed on the proxy, they answer for the whole network.
Two of them differ between the two sides:
| Tag |
On a backend |
On the proxy |
<unplugged-afk_count> |
How many this server holds |
How many the network holds |
<unplugged-afk_server> |
Not registered |
The server the unplugged player is on |
The rest carry the meanings listed above and render identically on either side.
Proxy Support
Velocity
Behind Velocity, /unplug needs to disconnect you from the whole network rather than from the single backend you are
on, and reconnecting needs to send you back to the backend holding your unplugged player. For this to work properly, the
companion JAR is required on the proxy.
Supported Velocity versions are listed under Requirements. Other versions are best-effort, and the
companion logs an error on startup when it cannot resolve the internals it needs.
Debug Mode
Everything here is gated behind the debug configuration flag, which is off by default.
/unplugged debug spawn-fake becomes available. It spawns a throwaway unplugged player with a random UUID and name.
Behind a proxy it needs the proxy to be reachable, just like /unplug.
- Every
/unplug writes a text file to plugins/unplugged-afk/dumps/ holding the session details and a full snapshot
of the player, inventory and ender chest included.
The proxy has its own debug flag, set independently of the backends'. It gates noisy console logging useful for
debugging.
Acknowledgements
Huge thanks to Sakura Ryoko for Unplugged AFK, the mod this ports. This
plugin would not exist without their work.
评论 0
登录后参与评分
还没有评论,来抢沙发吧