Перейти к содержимому
Mineforgian

Detect AFK Players

AFK/idle detection that's extremely performant · Players go AFK after 3 minutes (configurable) without moving their mouse · Extend with plenty of add-ons!

Загрузки
24K
Подписчики
54
Обновлён
26 июля 2025 г.
Лицензия
MIT

Опубликован 11 июля 2023 г.

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

Ченджлог

1.2.2+modРелиз1.21.6, 1.21.7, 1.21.8 · 26 июля 2025 г.

This update doesn't introduce any new functionality, but it does add compatibility for older versions of the game at the same time as newer versions thanks to the magic of having a build step.

1.2.2Релиз1.21.6, 1.21.7, 1.21.8 · 26 июля 2025 г.

This update doesn't introduce any new functionality, but it does add compatibility for older versions of the game at the same time as newer versions thanks to the magic of having a build step.

1.2.1+modРелиз1.21.3, 1.21.4, 1.21.5 · 11 апреля 2025 г.

This removes a debugging function that was causing harmless (but ugly) errors in the game logs, and bumps the data pack version.

1.2.1Релиз1.21.3, 1.21.4, 1.21.5 · 11 апреля 2025 г.

This removes a debugging function that was causing harmless (but ugly) errors in the game logs, and bumps the data pack version.

1.2+modРелиз1.21.3, 1.21.4, 1.21.5 · 30 марта 2025 г.

This version of the data pack maintains compatibility with previous versions but changes a lot internally.

This changelog doesn't go into much detail. For more information, read the documentation. A copy is included in a download of this data pack.

  • Improved the responsiveness of the AFK detection

    • The data pack is performant enough that on a low spec system it can easily run for upwards of 40 players on every tick while only increasing the MSPT by about 1 or 2. I'm only increasing the rate of checking from every 5 seconds to 1.5 seconds (1 in every 30 ticks)
  • Added an afk trigger

    • Admins can run /scoreboard players enable <username> afk to allow a player to manually become AFK
  • Added a new afk.ticks scoreboard, which can be used to track the amount of ticks that players have been AFK

  • A player exiting and re-joining the game is counted as active

  • Players leaving the game can be detected by add-ons without implementing a custom scoreboard

  • Added a configurable threshold for players becoming AFK, instead of hard-coding 3 minutes

    • An admin can run /scoreboard players set .threshold afk.settings <ticks>
    • 3600 ticks by default, which is 3 minutes
  • Changed scoreboard objective names. The names documented in the documentation are now stable and part of the public API.

1.2Релиз1.21.3, 1.21.4, 1.21.5 · 11 декабря 2024 г.

This version of the data pack maintains compatibility with previous versions but changes a lot internally.

This changelog doesn't go into much detail. For more information, read the documentation. A copy is included in a download of this data pack.

  • Improved the responsiveness of the AFK detection

    • The data pack is performant enough that on a low spec system it can easily run for upwards of 40 players on every tick while only increasing the MSPT by about 1 or 2. I'm only increasing the rate of checking from every 5 seconds to 1.5 seconds (1 in every 30 ticks)
  • Added an afk trigger

    • Admins can run /scoreboard players enable <username> afk to allow a player to manually become AFK
  • Added a new afk.ticks scoreboard, which can be used to track the amount of ticks that players have been AFK

  • A player exiting and re-joining the game is counted as active

  • Players leaving the game can be detected by add-ons without implementing a custom scoreboard

  • Added a configurable threshold for players becoming AFK, instead of hard-coding 3 minutes

    • An admin can run /scoreboard players set .threshold afk.settings <ticks>
    • 3600 ticks by default, which is 3 minutes
  • Changed scoreboard objective names. The names documented in the documentation are now stable and part of the public API.

1.1.1Релиз1.21.1, 1.21.2, 1.21.3 · 17 июня 2024 г.

Updated to support Minecraft 1.21.0, and corrects the previously incorrect older-version support. Because of the scoreboard names, only versions after 1.18 are supported. This version changes nothing from the previous version.

1.1Релиз1.20.2, 1.20.3, 1.20.4 · 25 февраля 2024 г.

Updated to guarantee that players are tagged with afk before #afk:away and #afk:back are called.

Комментарии

Загружаем…