AFK Actions

插件

· 作者 DevPanda

AFK Actions 是一款功能全面的 Minecraft Paper 插件,通过检测并管理 AFK(离开键盘)玩家,在指定的不活跃时间段后执行可自定义的命令。

0 本站下载 0 关注 更新于 1 年前

最新 1.5 · 1.21.10 · Paper / Purpur

一键开服(送7天)

AFK Actions

一款功能强大且丰富的 Paper/Purpur 服务器 AFK(挂机)检测插件,通过可自定义的命令和多语言支持自动管理空闲玩家。


? 特性

  • ? 自动 AFK 检测 - 追踪玩家移动和聊天活动
  • ⚙️ 双命令系统 - 当玩家进入或退出 AFK 状态时执行相应命令
  • ? 多语言支持 - 内置英语和土耳其语翻译(完全可定制)
  • ?️ 智能豁免 - OP 和基于权限的 AFK 免疫机制
  • ? 广播系统 - 向全服通知 AFK 状态变更
  • ? 调试模式 - 详细的日志记录以便故障排除
  • ? 管理命令 - 查看、列出和重置玩家的 AFK 状态
  • ⚡ 高性能 - 轻量级,对服务器影响极小
  • ? 完全可定制 - 每条消息和设置均可配置

? 要求

  • Minecraft: 1.21+
  • 服务器: Paper, Purpur 或任何基于 Paper 的服务器
  • Java: 21+

? 命令

所有命令均位于主命令 /afkactions 下(别名:/afk)

命令 权限 描述
/afkactions - 显示帮助菜单
/afkactions help - 显示可用命令
/afkactions reload afkactions.reload 重新加载配置文件和语言文件
/afkactions status <player> afkactions.status 查看玩家的详细 AFK 状态
/afkactions list afkactions.list 列出当前所有处于 AFK 状态的玩家
/afkactions reset <player> afkactions.reset 重置玩家的 AFK 状态

? 权限

管理员权限

权限 默认值 描述
afkactions.* op 授予所有 AFK Actions 权限
afkactions.reload op 重新加载插件配置
afkactions.status op 查看玩家 AFK 状态
afkactions.list op 列出所有 AFK 玩家
afkactions.reset op 重置玩家 AFK 状态

豁免权限

权限 默认值 描述
afkactions.bypass false 使玩家免受 AFK 系统影响 - 永远不会被标记为 AFK

⚙️ 配置

主配置文件 (config.yml)

# AFK Actions Plugin Configuration
# 所有时间单位均为秒

# 语言 (en = 英语, tr = 土耳其语)
language: "en"

# 调试模式 - 在控制台中显示详细日志 (默认: false)
debug: false

# AFK 检测时间 - 玩家在无活动后经过此时间将被标记为 AFK (秒)
afk-detection-time: 180

# 命令执行时间 - 玩家处于 AFK 状态超过此时间后将执行命令 (秒)
command-execution-time: 600

# 豁免设置
exemptions:
  # OP 是否应免除 AFK 系统?
  ignore-ops: true
  # 拥有 afkactions.bypass 权限的玩家自动获得豁免

# 广播设置
broadcast:
  # 是否向服务器广播 AFK 状态?
  afk-enabled: true
  # 是否向服务器广播从 AFK 返回的状态?
  return-enabled: true

# 当玩家变为 AFK 时执行的命令
# 以玩家身份运行的命令 (不要包含 /)
# 可用占位符: {player}
player-commands:
  - "server lobby"

# 从控制台运行的命令 (不要包含 /)
# 可用占位符: {player}
console-commands:
  - "kick {player} You have been AFK for too long!"

# 当玩家从 AFK 返回时执行的命令
# 以玩家身份运行的命令 (不要包含 /)
# 可用占位符: {player}
return-player-commands:
  - "spawn"

# 从控制台运行的命令 (不要包含 /)
# 可用占位符: {player}
return-console-commands:
  - "tell {player} Welcome back!"
  - "effect give {player} minecraft:speed 10 1"

? 语言文件

插件会在 plugins/AFKActions/ 中创建可定制的语言文件:

英语 (messages_en.yml)

土耳其语 (messages_tr.yml)

所有消息(包括广播、命令和错误信息)均可完全翻译!

更改语言:

language: "en"  # 或 "tr"

然后运行:/afkactions reload


? 工作原理

AFK 检测流程

  1. 玩家闲置 → 在配置的时间内没有移动或聊天
  2. AFK 状态 → 玩家被标记为 AFK(默认 3 分钟)
  3. 广播 → 服务器收到通知:{player} is now AFK!(如果启用)
  4. 等待期 → 在命令执行之前的额外等待时间
  5. 命令执行 → 总时间过后(默认 10 分钟),执行命令
  6. 玩家返回 → 发生移动/聊天时,清除 AFK 状态
  7. 返回广播 → 服务器收到通知:{player} is no longer AFK!(如果启用)
  8. 返回命令 → 可选命令在返回时立即执行

? 用例与示例

示例 1:踢出 AFK 玩家

afk-detection-time: 300      # 5 分钟
command-execution-time: 600  # 总共 10 分钟

player-commands: []
console-commands:
  - "kick {player} You were AFK for too long!"

示例 2:移至大厅

player-commands:
  - "server lobby"

console-commands:
  - "tell {player} Moving you to lobby due to inactivity"

示例 3:旁观者模式 + 返回系统

# 当处于 AFK 状态时
console-commands:
  - "gamemode spectator {player}"
  - "tell {player} You are now in spectator mode (AFK)"

# 当返回时
return-console-commands:
  - "gamemode survival {player}"
  - "effect give {player} minecraft:regeneration 30 2"
  - "tell {player} Welcome back! Restored to survival mode"

示例 4:经济/奖励系统

# 当从 AFK 返回时
return-console-commands:
  - "eco give {player} 100"
  - "title {player} title {\"text\":\"Welcome Back!\",\"color\":\"gold\"}"
  - "title {player} subtitle {\"text\":\"Here's $100!\",\"color\":\"yellow\"}"

?️ 豁免

OP 豁免(基于配置)

exemptions:
  ignore-ops: true  # OP 永远不会进入 AFK 状态

基于权限的豁免

授予 afkactions.bypass 权限以豁免特定玩家:

LuckPerms 示例:

# 豁免单个玩家
/lp user PlayerName permission set afkactions.bypass true

# 豁免 VIP 组
/lp group vip permission set afkactions.bypass true

# 豁免工作人员
/lp group admin permission set afkactions.bypass true
/lp group moderator permission set afkactions.bypass true

? 调试模式

启用调试模式以获取详细日志:

debug: true

控制台输出:

[AFKActions] [DEBUG] Executing 1 AFK player command(s) for PlayerName
[AFKActions] [DEBUG] AFK player command: server lobby
[AFKActions] [DEBUG] Executing 1 return console command(s) for PlayerName
[AFKActions] [DEBUG] Return console command: tell PlayerName Welcome back!

非常适合排查命令执行问题!


? 占位符

当前支持的占位符:

  • {player} - 玩家名称

适用于所有命令列表(玩家/控制台,闲置/返回)


? 状态命令详情

/afkactions status <player> 显示:

  • ✅ 玩家名称
  • ? 闲置状态(AFK / Active)
  • ⏰ 距离上次活动的时间
  • ⚙️ 已执行命令的状态
  • ⏳ 直到命令执行剩余的等待时间(如果处于闲置状态)

非常适合管理员检查玩家活跃度!


? 自定义技巧

自定义消息

编辑 plugins/AFKActions/ 中的语言文件:

  • messages_en.yml - 英文消息
  • messages_tr.yml - 土耳其语消息

所有颜色均使用 & 代码:&a = 绿色,&c = 红色,&e = 黄色,等等。

多条命令

您可以为每个操作添加多条命令:

console-commands:
  - "tell {player} You are AFK!"
  - "title {player} title {\"text\":\"AFK\",\"color\":\"red\"}"
  - "gamemode spectator {player}"
  - "tp {player} 0 100 0"

BungeeCord/Velocity 支持

对于网络服务器,请使用控制台命令:

BungeeCord:

console-commands:
  - "send {player} lobby"

Velocity:

console-commands:
  - "server {player} lobby"

? 性能

  • ✅ 轻量级 - 每秒运行一次检测,CPU 占用极低
  • ✅ 并发 HashMaps - 线程安全的玩家追踪
  • ✅ 高效的调度 - 使用 Bukkit 的任务系统
  • ✅ 无需数据库 - 所有数据存储在内存中
  • ✅ 自动清理 - 玩家断开连接时移除玩家数据

? 安装

  1. 下载最新版本
  2. 将 JAR 文件放入服务器的 plugins 文件夹
  3. 重启或重载服务器
  4. 配置 plugins/AFKActions/config.yml
  5. 可选:自定义语言文件
  6. 运行 /afkactions reload 应用更改

? 许可证

本插件可免费使用和修改。


⭐ 鸣谢

开发者: DevPanda (Efe Dönmez) API: Paper 1.21+ 编程语言: Kotlin


用 ❤️ 为 Minecraft 社区制作

你是这个资源的作者?登录后可认领此资源。

评论 0

0.0
暂无评分
5 星
0
4 星
0
3 星
0
2 星
0
1 星
0
我的评分

登录后参与评分

还没有评论,来抢沙发吧

评论配图

相似资源