LeaveReason

Detect abnormal player disconnections (kick, timeout, ban, not whitelisted) and broadcast the reason to chat

information

Installation command

!!MCDR plugin install leave_reason

Synced at

...

Last update

...

Latest version

Total downloads

7

Back to catalogue

LeaveReason

Detects abnormal player disconnections (kick, timeout, ban, not whitelisted) and broadcasts the reason to chat.

Same plugin used by the AZ Tech Server, review group 1101978932.

Parses server logs and fills in the "why" when a player leaves. The "who left" part itself is shown by the server or a chat forwarding plugin.

Detectable reasons

ReasonPublic chat example
Kickedxxx left the game, reason: kicked from server (You have been removed)
Connection timeoutxxx left the game, reason: connection timed out
Bannedxxx left the game, reason: banned
Not whitelistedxxx left the game, reason: not whitelisted
Uncategorizedxxx left the game, reason: Attempting to attack an invalid entity

All texts are configurable.

How it works

  • Kicked / timeout happen in-game, log is <player> lost connection: <reason>, player name is available directly.
  • Banned is blocked by vanilla banlist.json at login, log is Disconnecting <address>: You are banned ....
  • Whitelist is blocked by vanilla whitelist.json at login, log is Disconnecting <address>: You are not white-listed ....

When banned / whitelist blocks at login, the log usually has no player name, so message_no_name is used instead. The backend log just doesn't record it — not a bug.

Installation

Drop leave_reason.mcdr into MCDR's plugins/ directory, then !!MCDR plugin load leave_reason.mcdr (or restart).

Commands

CommandDescriptionPermission
!!lrHelp4
!!lr on / !!lr offToggle broadcast4
!!lr reloadReload config4
!!lr statusShow status4

Permission level 4 = owner / console. Prefix !!lr is the PREFIX constant in the code.

Configuration

config/leave_reason/config.json is generated on first load, apply changes with !!lr reload. Common fields:

FieldPurpose
enabledMaster switch
message / message_no_nameMessage format, {player}=name, {reason}=reason
reason_textText for the four categories (kick / timeout / ban / whitelist)
append_kick_detailAppend the raw kick reason
show_unknownAlso broadcast unmatched reasons
dedup_secondsDedup window per player + reason
keywordsClassification keywords

Minimal config:

{
    "config_version": 2,
    "enabled": true,
    "message": "§7[§c!§7] §e{player} §7left the game, reason: §f{reason}",
    "message_no_name": "§7[§c!§7] §eA player §7was refused to join, reason: §f{reason}",
    "reason_text": {
        "kick": "Kicked from server",
        "timeout": "Connection timed out",
        "ban": "Banned",
        "whitelist": "Not whitelisted"
    }
}

Upgrading from 1.2.x: old configs without config_version get backed up as config.json.bak.

Tuning

  1. Set debug to true and !!lr reload, test with a non-whitelisted player and a banned player, check the [leave_reason][debug] output.
  2. If the whitelist block isn't vanilla not white-listed but a plugin kicking players, add keywords from that custom text to keywords.whitelist.
  3. Normal disconnects (Disconnected) are ignored in keywords.ignore by default; remove it to detect them.

Feedback

QQ: 2683654412.

Introduction source: src/README_en.md