Module: afk
Overview
This module adds a checker to check if a player is in Away From Keyboard state.
With the afk state:
-
You can define
commandsto be executed when a playerentersorleavesthis state. -
You can define the
display namein this state.
Color Boxes
◉ 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.
- File Name:
config.json - File Content:
Click to see the default content...
{
/* 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 Name:
AfkCheckerJob - Document: This
jobis used to compare and mark a player as in afk state.
Commands
-
Command Syntax:
/afk -
Document: Enter afk state.
-
Can be executed by console:
false -
Required Level Permission:
0
-
Command Syntax:
/afk others <PlayerCollection others> -
Document: Enter afk state.
-
Can be executed by console:
true -
Required Level Permission:
4
-
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