Class PlayerLoginEvent


@Deprecated(since="1.21.6") public class PlayerLoginEvent extends PlayerEvent
Deprecated.
Use PlayerConnectionValidateLoginEvent to handle pre-login logic (e.g. authentication or ban checks), or PlayerServerFullCheckEvent to allow players to bypass the server's maximum player limit. Minecraft triggers this twice internally, using this event skips one of the validation checks done by the server. Additionally, this event causes the full player entity to be created much earlier than it would be in Vanilla, leaving it with mostly dysfunctional methods and state.
Stores details for players attempting to log in.
Note that this event is called early in the player initialization process. It is recommended that most options involving the Player entity be postponed to the PlayerJoinEvent instead.
  • Constructor Details

    • PlayerLoginEvent

      @Internal public PlayerLoginEvent(@NotNull @NotNull Player player, @NotNull @NotNull String hostname, @NotNull @NotNull InetAddress address, @NotNull @NotNull InetAddress realAddress)
      Deprecated.
    • PlayerLoginEvent

      @Internal public PlayerLoginEvent(@NotNull @NotNull Player player, @NotNull @NotNull String hostname, @NotNull @NotNull InetAddress address)
      Deprecated.
    • PlayerLoginEvent

      @Internal @Deprecated(forRemoval=true) public PlayerLoginEvent(@NotNull @NotNull Player player, @NotNull @NotNull String hostname, @NotNull @NotNull InetAddress address, @NotNull @NotNull PlayerLoginEvent.Result result, @NotNull @NotNull String message, @NotNull @NotNull InetAddress realAddress)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • PlayerLoginEvent

      @Internal public PlayerLoginEvent(@NotNull @NotNull Player player, @NotNull @NotNull String hostname, @NotNull @NotNull InetAddress address, @NotNull @NotNull PlayerLoginEvent.Result result, @NotNull Component message, @NotNull @NotNull InetAddress realAddress)
      Deprecated.
  • Method Details

    • getHostname

      @NotNull public @NotNull String getHostname()
      Deprecated.
      Gets the hostname that the player used to connect to the server, or blank if unknown
      Returns:
      The hostname
    • getAddress

      @NotNull public @NotNull InetAddress getAddress()
      Deprecated.
      Gets the InetAddress for the Player associated with this event. This method is provided as a workaround for player.getAddress() returning null during PlayerLoginEvent.
      Returns:
      The address for this player. For legacy compatibility, this may be null.
    • getRealAddress

      @NotNull public @NotNull InetAddress getRealAddress()
      Deprecated.
      Gets the connection address of this player, regardless of whether it has been spoofed or not.
      Returns:
      the player's connection address
      See Also:
    • getResult

      @NotNull public @NotNull PlayerLoginEvent.Result getResult()
      Deprecated.
      Gets the current result of the login, as an enum
      Returns:
      Current Result of the login
    • setResult

      public void setResult(@NotNull @NotNull PlayerLoginEvent.Result result)
      Deprecated.
      Sets the new result of the login, as an enum
      Parameters:
      result - New result to set
    • kickMessage

      @NotNull public @NotNull Component kickMessage()
      Deprecated.
      Gets the current kick message that will be used when the outcome is not allowed
      Returns:
      Current kick message
    • kickMessage

      public void kickMessage(@NotNull @NotNull Component message)
      Deprecated.
      Sets the kick message to display when the outcome is not allowed
      Parameters:
      message - New kick message
    • getKickMessage

      @NotNull @Deprecated public @NotNull String getKickMessage()
      Deprecated.
      in favour of kickMessage()
      Gets the current kick message that will be used when the outcome is not allowed
      Returns:
      Current kick message
    • setKickMessage

      @Deprecated public void setKickMessage(@NotNull @NotNull String message)
      Deprecated.
      Sets the kick message to display when the outcome is not allowed
      Parameters:
      message - New kick message
    • allow

      public void allow()
      Deprecated.
      Allows the player to log in
    • disallow

      @Deprecated public void disallow(@NotNull @NotNull PlayerLoginEvent.Result result, @NotNull @NotNull String message)
      Deprecated.
      Disallows the player from logging in, with the given reason
      Parameters:
      result - New result for disallowing the player
      message - Kick message to display to the user
    • disallow

      public void disallow(@NotNull @NotNull PlayerLoginEvent.Result result, @NotNull @NotNull Component message)
      Deprecated.
      Disallows the player from logging in, with the given reason
      Parameters:
      result - New result for disallowing the player
      message - Kick message to display to the user
    • getHandlers

      @NotNull public @NotNull HandlerList getHandlers()
      Deprecated.
      Specified by:
      getHandlers in class Event
    • getHandlerList

      @NotNull public static @NotNull HandlerList getHandlerList()
      Deprecated.