RA-AfkStatus

A lightweight Paper 1.21.x plugin that detects and manages AFK status for players, with anti-piston abuse protection and PlaceholderAPI support.

Author: RajaAditya Website: rajaaditya.my.id Version: 1.0 API: Paper 1.21.x (1.21, 1.21.1, 1.21.2, 1.21.3, 1.21.4)


Overview

RA-AfkStatus is a lightweight standalone plugin for Paper 1.21.x that detects and manages AFK (Away From Keyboard) status for players. Designed for OneBlock servers where players frequently leave their characters idle during AFK farms.

  • Automatic AFK detection based on position tracking
  • Manual AFK toggle via /afk
  • Anti-piston abuse protection (3-block exit threshold)
  • Admin AFK list with /afk list
  • Live config reload via /afk reload
  • PlaceholderAPI support
  • Fully customizable messages via messages.yml
  • No island plugin dependencies
  • Console-compatible admin commands

Dependencies

DependencyTypeVersion
PaperServer1.21.x
JavaRuntime21
PlaceholderAPIRequired2.11+

Installation

  1. Download RA-AfkStatus-1.0.jar
  2. Place it in your plugins/ folder
  3. Ensure PlaceholderAPI is installed
  4. Start or restart the server
  5. The plugin will auto-generate config.yml and messages.yml
  6. Run /afk reload after editing any configuration file

No server restart required after editing configuration files.


AFK Detection System

How It Works

A scheduler runs every 30 seconds and checks each online player:

  1. Records the player's current position
  2. Compares it with the last recorded position
  3. If position has not changed for afk-timeout-minutes → player is marked AFK
  4. When an AFK player moves 3 or more blocks from their AFK entry position → AFK is removed

Automatic Detection

TriggerAction
No movement for X minutesPlayer marked AFK automatically
Moved 3+ blocks from AFK positionAFK removed automatically
Player joinsInitialized in tracking system
Player quitsRemoved from all tracking maps

Manual Toggle

CommandAction
/afkToggles AFK on if not AFK, off if already AFK

Commands

Player Commands

CommandDescriptionPermission
/afkToggle AFK statusNone

Admin Commands

CommandDescriptionPermission
/afk listList all AFK playersraafkstatus.list
/afk reloadReload config filesraafkstatus.reload

Command Output Examples

/afk (player):

text
1
[RA-AfkStatus] You are now marked as AFK.

/afk list:

text
1
[RA-AfkStatus] Players currently AFK:
- Steve
- Alex

/afk reload:

text
1
[RA-AfkStatus] Config and messages reloaded successfully.

Permissions

PermissionDefaultDescription
raafkstatus.listopUse /afk list
raafkstatus.reloadopUse /afk reload

Configuration

config.yml

yaml
1
# How many minutes of no movement before a player is marked as AFK
afk-timeout-minutes: 5

# The value shown in %afkstatus_status% when the player is AFK
# Supports & color codes
afk-placeholder-value: "&7[AFK]"

Settings reference:

SettingTypeDefaultDescription
afk-timeout-minutesInteger5Minutes of no movement before AFK
afk-placeholder-valueString&7[AFK]Placeholder value shown when player is AFK

messages.yml

yaml
1
# All messages support & color codes
# Use {player} for player name where applicable

prefix: "&8[&bRA-AfkStatus&8] "

afk-auto-enter:           "{prefix}&7You are now AFK."
afk-manual-enter:         "{prefix}&7You are now marked as AFK."
afk-auto-leave:           "{prefix}&aWelcome back!"
afk-manual-leave:         "{prefix}&aYou are no longer AFK."
afk-list-header:          "{prefix}&ePlayers currently AFK:"
afk-list-entry:           "&7- &f{player}"
afk-list-empty:           "{prefix}&7No players are currently AFK."
afk-list-no-permission:   "{prefix}&cYou do not have permission to use this command."
afk-reload-success:       "{prefix}&aConfig and messages reloaded successfully."
afk-reload-no-permission: "{prefix}&cYou do not have permission to reload the config."

Message variables:

PlaceholderDescription
{prefix}Plugin message prefix
{player}Player name (list entries only)

Supported color codes:

CodeColor
&aGreen
&cRed
&eYellow
&7Gray
&bAqua
&8Dark Gray
&fWhite

PlaceholderAPI

PlaceholderReturns
%afkstatus_status%Value from afk-placeholder-value if AFK, empty string if not

Usage examples:

Scoreboard:

text
1
%afkstatus_status%

Tablist:

text
1
%player_name% %afkstatus_status%

Chat format:

text
1
%afkstatus_status% %player_name%: %message%

Anti-Piston Abuse

Some servers use pistons or water streams to slightly nudge AFK players, which would falsely reset AFK status on simple position-check plugins.

RA-AfkStatus stores the exact position when the player became AFK. AFK is only removed when the player moves 3 or more blocks (Euclidean distance) from that stored position — preventing pistons, knockback, or minor adjustments from resetting the status.

ConditionResult
Moved less than 3 blocks from AFK positionStay AFK
Moved 3+ blocks from AFK positionAFK removed

FAQ

How do I change the AFK timeout? Edit afk-timeout-minutes in config.yml, then run /afk reload.

How do I change the placeholder text? Edit afk-placeholder-value in config.yml, then run /afk reload.

Can I customize messages? Yes — edit messages.yml and run /afk reload.

Does this plugin require an island plugin? No, RA-AfkStatus has no dependencies on island or OneBlock plugins.

Does /afk list work from console? Yes, both players (with permission) and console can use /afk list.

What Paper versions are supported? Paper 1.21, 1.21.1, 1.21.2, 1.21.3, and 1.21.4.

Where is player data stored? In memory only — no flat file storage. Data resets on server restart.