Skip to main content

Module: afk

Overview​

Module

This module adds a checker to check if a player is in Away From Keyboard state.

With the afk state:

  1. You can define commands to be executed when a player enters or leaves this state.

  2. You can define the display name in this state.

Color Boxes​

Note

◉ How it works?

➜ Track the last action time

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

The actions can be: mine a block, movement, issue a command...

When an action received from a player, update the number for that player.

➜ Enter the afk state

Define a job to compare 2 consecutive values of the number.

If the values are identical, then cause the player to enter the afk state.

Besides that, a player can use /afk command to enter it manually.

➜ Leave the afk state

When an action received from a player, it causes the player to leave the afk state.

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
{
/* Define the `display name` of a player in afk state. */
"afk_display_name_format": "<gray>[AFK] %player:displayname_visual%"
/* An afk checker is used to compare and mark a player as in afk state. */,
"afk_checker": {
"cron": "0 0/5 * ? * *"
}
/* Define commands to be executed when a player enters or leaves the afk state. */,
"afk_event": {
"on_enter_afk_commands": [
"send-broadcast <gold>Player %player:name% is now afk"
],
"on_leave_afk_commands": [
"send-broadcast <gold>Player %player:name% is no longer afk"
]
}
}

Jobs​

Job
  • Job Name: AfkCheckerJob
  • Document: This job is used to compare and mark a player as in afk state.

Commands​

Command
  • Command Syntax: /afk

  • Document: Enter afk state.

  • Can be executed by console: false

  • Required Level Permission: 0

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

  • Document: Enter afk state.

  • Can be executed by console: true

  • Required Level Permission: 4

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

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

  • Can be executed by console: true

  • Required Level Permission: 4