Skip to content

PlayerQuitEvent.QuitType API suggestion #254

@ghost

Description

While looking at player quit related stuff, I saw that the actual "quit reason" is logged to console, but this not exposed via an API.

After a little bit of testing it appears that there are 4 different types of leaving the game, with each having their own log reason:

  • Leaving normally: "Disconnected"
  • Timing out: "TImed out"
  • Being kicked from the server: Kick message
  • Crashing: Exception message

Based on this, I suggest the addition of the following enum to PlayerQuitEvent:

public enum QuitType {
    /**
     * The player left on his own behalf.
     */
    DISCONNECTED,

    /**
     * The player was kicked from the server.
     */
    KICKED,

    /**
     * The player has crashed from the server.
     */
    CRASHED,

    /**
     * The player has timed out.
     */
    TIMED_OUT
}

and the addition of two new methods inside PlayerQuitEvent:

  • public QuitType getQuitType() { /* .. */ } - Self explanatory
  • public String getCrashReason() { /* .. */ } - Obtain the exception message when a player has crashed. IllegalStateException UnsupportedOperationException if getQuitType() != QuitType.CRASHED.

Technically it is possible to implement this as a plugin by adding a custom Appender to the PlayerConnection logger but that seems very hack-ish. (My horrible plugin side code can be found here in case there's interest).

As I'm unable to get a dev environment up and running (damn Windows..) I cannot implement this myself. :(

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: featureRequest for a new Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions