Unplugged AFK: Paper Edition
在不关闭电脑的情况下保持离线挂机状态。/unplug 命令会断开你的连接,并在原地留下一个与你完全相同的机器人——拥有相同的皮肤、相同的生存模式,并显示在玩家列表中——这样即使你关闭了机器,农场也能继续运行。重新登录时,你会接管机器人的位置。
这是 sakura-ryoko 的 Unplugged-AFK Fabric 模组的 Paper 插件移植版本。
要求
- Paper 26.2(或其分支)。不支持 Spigot 或 Bukkit —— 此插件使用了仅 Paper 内部的功能。
- Java 25,这也是 Paper 26.2 所要求的。
将 jar 文件放入 plugins/ 目录并重启服务器即可。无需其他依赖项。
此插件会从玩家列表中移除玩家并重写其 .dat 文件 —— 这是它的工作原理,而非副作用。建议先在测试服务器上尝试,或提前备份数据。
工作原理
执行 /unplug 后,服务器会将你踢出,并在下一个游戏刻(tick)在你所在的位置放置一个真正的服务端玩家实体。这是一个真实的 ServerPlayer,因此它可以保持区块加载、推动农场运作、显示在标签页中,并且可以被伤害或杀死。
会话状态会在重启后保留:机器人会在服务器关闭时将配置写入配置文件,并在启动时重新生成,每次重生间隔数秒,同时从剩余时间内扣除停机时间。
命令
玩家
| 命令 |
描述 |
/unplug [<分钟数>] [<原因>] |
断开连接并留下一个机器人。 |
/afk [<分钟数>] [<原因>] |
相同的别名,默认关闭。如果其他插件已拥有 /afk,则自动跳过。 |
管理
/unplugged-admin — 默认为操作员权限。
| 子命令 |
说明 |
save / reload |
写入或重新读取配置文件。 |
list [players|unplugged|all] |
显示已跟踪的玩家和在线机器人。 |
info [<player>] |
查看单个玩家的详细状态。 |
purge |
清除所有已跟踪的玩家并重新同步。 |
spawn <player> [<minutes>] [<reason>] |
为离线玩家生成一个机器人。 |
kick <target> |
移除一个机器人并结束其会话。 |
| set <选项> <值> | 更改任意配置选项,然后保存并重新加载。 |
子命令 info、list players|unplugged|all 和 set 需要在配置文件中启用 advancedAdminOptions。
权限
| 节点 |
默认权限 |
授予权限 |
unplugged_afk.unplug |
所有人 |
/unplug |
unplugged_afk.afk |
所有人 |
/afk |
unplugged_afk.unplugged-admin |
操作员 |
/unplugged-admin |
unplugged_afk.unplugged-admin.<subcommand> |
操作员 |
一个子命令。 |
若未设置节点,插件会回退到 commands 中配置的操作员级别,这与 Fabric 模组的行为一致。
限制会话时长
| 节点 |
授予 |
unplugged_afk.maxtime.<minutes> |
上限,单位为分钟。 |
unplugged_afk.maxtime.unlimited |
无上限。 |
玩家拥有的最高权限节点生效,因此拥有多个组别的玩家将获得最慷慨的那个。若未授予任何节点,则上限为 defaultUnpluggedTimeout。
该上限同时适用于默认值和显式参数,因此拥有 maxtime.60 的玩家在执行 /unplug 时可获得 60 分钟。若请求超过上限,则会被钳制并提示相应信息。
# LuckPerms: 让普通玩家挂机一天,捐赠者无限期挂机
/lp group default permission set unplugged_afk.maxtime.1440 true
/lp group donor permission set unplugged_afk.maxtime.unlimited true
配置
请参阅 CONFIG.md。配置文件位于
plugins/unplugged-afk-paper-edition/unplugged-afk-paper-edition.json,并且会自动采用来自 Fabric 模组或早期构建版本的配置。
面向开发者
UnpluggedAfkAPI 暴露了会话状态,并在会话开始、重生和结束时触发三个 Bukkit 事件。
if (UnpluggedAfkAPI.isUnplugged(player.getUniqueId()))
{
// 该 "player" 是一个机器人
}
@EventHandler
public void onUnplugged(UnpluggedStartEvent event)
{
getLogger().info(event.getPlayerId() + " went AFK");
}
与 Fabric 模组的差异
其他行为保持一致。已知差异如下:
- 机器人出现稍晚几个刻。 Paper 会将断开连接延迟一个刻,因此机器人是在玩家完全消失后才被放置,而非立即。
- ** slime-block(史莱姆块)飞行机器人为近似效果。** 推力应用于机器人自身的刻,而非活塞移动代码内部,因此高速机器可能表现不同。
- 逃离末地是普通的传送。 原版在重生期间替换了玩家,而 Paper 不允许此操作。
resetHealthUponDeath 实际上会保持会话存活。 在 Fabric 模组中,它会治疗机器人并无论如何结束会话。
- 单一版本支持。 此版本仅针对 Paper 26.2,而原模组支持从 1.19.2 到 26.2 的版本。
其他插件将机器人视为从 127.0.0.1 加入和离开的普通玩家。反作弊系统尤其可能会反对没有客户端却移动的玩家;如果遇到这种情况,请豁免机器人或启用 unpluggedHidePlayer。
构建
./gradlew build
jar 包将写入 build/libs/。
许可证
LGPL-3.0,继承自原始模组。版权归 sakura-ryoko 及其贡献者所有;详见文件头部注释。
Unplugged AFK: Paper Edition
Stay AFK without leaving your computer on. /unplug disconnects you and leaves
a bot standing exactly where you were — same skin, same gamemode, in the tab
list — so your farms keep running while your machine is off. Log back in and
you take its place.
A Paper plugin port of sakura-ryoko's Unplugged-AFK
Fabric mod.
Requirements
- Paper 26.2 (or a fork of it). Not Spigot or Bukkit — this uses Paper-only
internals.
- Java 25, which Paper 26.2 requires anyway.
Drop the jar in plugins/ and restart. There are no other dependencies.
This plugin removes players from the player list and rewrites their .dat
files — that is how it works, not a side effect. Try it on a test server or
take a backup first.
How it works
/unplug kicks you, then places a real server-side player in your position on
the next tick. It is a genuine ServerPlayer, so it keeps chunks loaded, ticks
farms, shows up in the tab list, and can be hurt or killed.
Sessions survive a restart: bots are written to the config on shutdown and
respawned on boot, staggered a few seconds apart, with the downtime subtracted
from their remaining time.
Commands
Players
| Command |
Description |
/unplug [<minutes>] [<reason>] |
Disconnect and leave a bot behind. |
/afk [<minutes>] [<reason>] |
Identical alias, off by default. Skipped automatically if another plugin owns /afk. |
Administration
/unplugged-admin — operator by default.
| Subcommand |
Description |
save / reload |
Write or re-read the config. |
list [players|unplugged|all] |
Show tracked players and live bots. |
info [<player>] |
Detailed state for one player. |
purge |
Drop all tracked players and resync. |
spawn <player> [<minutes>] [<reason>] |
Spawn a bot for an offline player. |
kick <target> |
Remove a bot and end its session. |
set <option> <value> |
Change any config option, then save and reload. |
The subcommands info, list players|unplugged|all and set require
advancedAdminOptions to be enabled in the config.
Permissions
| Node |
Default |
Grants |
unplugged_afk.unplug |
everyone |
/unplug |
unplugged_afk.afk |
everyone |
/afk |
unplugged_afk.unplugged-admin |
operator |
/unplugged-admin |
unplugged_afk.unplugged-admin.<subcommand> |
operator |
One subcommand. |
Where no node is set, the plugin falls back to the operator level configured in
commands, matching how the Fabric mod behaved.
Limiting session length
| Node |
Grants |
unplugged_afk.maxtime.<minutes> |
A ceiling, in minutes. |
unplugged_afk.maxtime.unlimited |
No ceiling. |
The highest node a player holds wins, so someone in several groups gets the most
generous one. With no node granted, the ceiling is defaultUnpluggedTimeout.
The ceiling applies to the default as well as to an explicit argument, so a
player with maxtime.60 gets 60 minutes from a bare /unplug. Asking for more
clamps and says so.
# LuckPerms: let regulars idle for a day, donors indefinitely
/lp group default permission set unplugged_afk.maxtime.1440 true
/lp group donor permission set unplugged_afk.maxtime.unlimited true
Configuration
See CONFIG.md. The file lives at
plugins/unplugged-afk-paper-edition/unplugged-afk-paper-edition.json, and a
config from the Fabric mod or an earlier build is adopted automatically.
For developers
UnpluggedAfkAPI exposes session state, and three Bukkit events fire as
sessions begin, respawn and end.
if (UnpluggedAfkAPI.isUnplugged(player.getUniqueId()))
{
// that "player" is a bot
}
@EventHandler
public void onUnplugged(UnpluggedStartEvent event)
{
getLogger().info(event.getPlayerId() + " went AFK");
}
Differences from the Fabric mod
Behaviour is otherwise the same. Known differences:
- Bots appear a few ticks later. Paper defers disconnects by a tick, so the
bot is placed after the player is fully gone rather than instantly.
- Slime-block flying machines are approximate. The push is applied from the
bot's own tick instead of from inside the piston's movement code, so fast
machines may behave differently.
- Escaping the End is a plain teleport. The original substituted the player
during respawn, which Paper does not allow.
resetHealthUponDeath actually keeps the session alive. In the Fabric mod
it healed the bot and ended the session anyway.
- Single version. This targets Paper 26.2 only, where the mod supported
1.19.2 through 26.2.
Other plugins see bots as ordinary players joining and quitting, from
127.0.0.1. Anticheats in particular may object to a player that moves without
a client; if you hit that, exempt the bots or turn on unpluggedHidePlayer.
Building
./gradlew build
The jar is written to build/libs/.
Licence
LGPL-3.0, inherited from the original mod. Copyright remains with sakura-ryoko
and contributors; see the file headers.
评论 0
登录后参与评分
还没有评论,来抢沙发吧