Skip to main content

Module: afk

Overview

Module

This module provides:

  1. Afk Detection: When a player remains idle beyond a specified threshold, they are marked as being in the AFK state.

  2. Afk Event: Execute configured commands when a player enters or leaves the afk state.

  3. Afk Name Customization: Allows customization of the display name of AFK players.

Color Boxes

Note

◉ How it works?

For each player, define a number to track the last action time.

Actions can be: mine a block, movement, issue a command ...

When action received, update the number.

Define a job using cron, to be triggered periodically.

The job will check and compare 2 consecutive value of the number.

If number is identical, then the player is considered as in afk.

Configurations

The following JSON content is provided for reference only. It must NOT be copied directly into the configuration directory, as it does not represent valid JSON syntax.

Config
  • File Name: config.json
  • File Content:
Click to see the default content...
config/fuji/modules/afk/config.json
{
/* The `display name` of an afk player in `tab` list. */
"afk_display_name_format": "<gray>[AFK] %player:displayname_visual%"
/* Afk checker is `triggered` periodically.
To check whether a player has any input action.
And mark the player as `afk` if there is no `action` for too long. */,
"afk_checker": {
"cron": "0 0/5 * ? * *"
}
/* Define commands to run on afk events. */,
"afk_event": {
"on_enter_afk": [
"send-broadcast <gold>Player %player:name% is now afk"
],
"on_leave_afk": [
"send-broadcast <gold>Player %player:name% is no longer afk"
]
}
}

Jobs

Job
  • Job Name: AfkMarkerJob
  • Document: This job is used to check the last action time for each player.

Commands

Command
  • Command Syntax: /afk

  • Document: Enter afk state.

  • Can be executed by console: false

  • Required Level Permission: 0

  • Required String Permission: null

Command
  • Command Syntax: /afk others <PlayerCollection others>

  • Document: Enter afk state.

  • Can be executed by console: false

  • Required Level Permission: 4

  • Required String Permission: null

Command
  • Command Syntax: /is-afk? <ServerPlayerEntity player>

  • Document: Test if a player is in afk state.

  • Can be executed by console: true

  • Required Level Permission: 4

  • Required String Permission: null