Package org.bukkit.event.player

# Class PlayerLoginEvent

java.lang.Object
org.bukkit.event.Event
org.bukkit.event.player.PlayerEvent
org.bukkit.event.player.PlayerLoginEvent

public class PlayerLoginEvent extends PlayerEvent
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.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static enum`
`PlayerLoginEvent.Result`
Basic kick reasons for communicating to plugins

## Field Summary

### Fields inherited from class org.bukkit.event.player.PlayerEvent

`player`

## Constructor Summary

Constructors
Constructor
Description
`PlayerLoginEvent(@NotNull Player player, @NotNull String hostname, @NotNull InetAddress address)`
`PlayerLoginEvent(@NotNull Player player, @NotNull String hostname, @NotNull InetAddress address, @NotNull InetAddress realAddress)`
This constructor defaults message to an empty string, and result to ALLOWED
`PlayerLoginEvent(@NotNull Player player, @NotNull String hostname, @NotNull InetAddress address, @NotNull PlayerLoginEvent.Result result, @NotNull String message, @NotNull InetAddress realAddress)`
Deprecated.
in favour of `PlayerLoginEvent(Player, String, InetAddress, Result, net.kyori.adventure.text.Component, InetAddress)`
`PlayerLoginEvent(@NotNull Player player, @NotNull String hostname, @NotNull InetAddress address, @NotNull PlayerLoginEvent.Result result, Component message, @NotNull InetAddress realAddress)`
This constructor pre-configures the event with a result and message

## Method Summary

Modifier and Type
Method
Description
`void`
`allow()`
Allows the player to log in
`void`
`disallow(@NotNull PlayerLoginEvent.Result result, @NotNull String message)`
Deprecated.
in favour of `disallow(Result, net.kyori.adventure.text.Component)`
`void`
`disallow(@NotNull PlayerLoginEvent.Result result, Component message)`
Disallows the player from logging in, with the given reason
`@NotNull InetAddress`
`getAddress()`
Gets the `InetAddress` for the Player associated with this event.
`static @NotNull HandlerList`
`getHandlerList()`
`@NotNull HandlerList`
`getHandlers()`
`@NotNull String`
`getHostname()`
Gets the hostname that the player used to connect to the server, or blank if unknown
`@NotNull String`
`getKickMessage()`
Deprecated.
in favour of `kickMessage()`
`@NotNull InetAddress`
`getRealAddress()`
Gets the connection address of this player, regardless of whether it has been spoofed or not.
`@NotNull PlayerLoginEvent.Result`
`getResult()`
Gets the current result of the login, as an enum
`Component`
`kickMessage()`
Gets the current kick message that will be used if getResult() != Result.ALLOWED
`void`
`kickMessage(Component message)`
Sets the kick message to display if getResult() != Result.ALLOWED
`void`
`setKickMessage(@NotNull String message)`
Deprecated.
in favour of `kickMessage(net.kyori.adventure.text.Component)`
`void`
`setResult(@NotNull PlayerLoginEvent.Result result)`
Sets the new result of the login, as an enum

### Methods inherited from class org.bukkit.event.player.PlayerEvent

`getPlayer`

### Methods inherited from class org.bukkit.event.Event

`callEvent, getEventName, isAsynchronous`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### PlayerLoginEvent

public PlayerLoginEvent(@NotNull @NotNull Player player, @NotNull @NotNull String hostname, @NotNull @NotNull InetAddress address, @NotNull @NotNull InetAddress realAddress)
This constructor defaults message to an empty string, and result to ALLOWED

Parameters:
  `player` - The `Player` for this event
  `hostname` - The hostname that was used to connect to the server
  `address` - The address the player used to connect, provided for timing issues
  `realAddress` - the actual, unspoofed connecting address

### PlayerLoginEvent

public PlayerLoginEvent(@NotNull @NotNull Player player, @NotNull @NotNull String hostname, @NotNull @NotNull InetAddress address)

### PlayerLoginEvent

@Deprecated 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.
in favour of `PlayerLoginEvent(Player, String, InetAddress, Result, net.kyori.adventure.text.Component, InetAddress)`
This constructor pre-configures the event with a result and message

Parameters:
  `player` - The `Player` for this event
  `hostname` - The hostname that was used to connect to the server
  `address` - The address the player used to connect, provided for timing issues
  `result` - The result status for this event
  `message` - The message to be displayed if result denies login
  `realAddress` - the actual, unspoofed connecting address

### PlayerLoginEvent

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)
This constructor pre-configures the event with a result and message

Parameters:
  `player` - The `Player` for this event
  `hostname` - The hostname that was used to connect to the server
  `address` - The address the player used to connect, provided for timing issues
  `result` - The result status for this event
  `message` - The message to be displayed if result denies login
  `realAddress` - the actual, unspoofed connecting address

## Method Details

### kickMessage

@NotNull public Component kickMessage()
Gets the current kick message that will be used if getResult() != Result.ALLOWED

Returns:
  Current kick message

### kickMessage

public void kickMessage(@NotNull Component message)
Sets the kick message to display if getResult() != Result.ALLOWED

Parameters:
  `message` - New kick message

### getRealAddress

@NotNull public @NotNull InetAddress getRealAddress()
Gets the connection address of this player, regardless of whether it has been spoofed or not.

Returns:
  the player's connection address

### getResult

@NotNull public @NotNull PlayerLoginEvent.Result getResult()
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)
Sets the new result of the login, as an enum

Parameters:
  `result` - New result to set

### getKickMessage

@NotNull @Deprecated public @NotNull String getKickMessage()
Deprecated.
in favour of `kickMessage()`
Gets the current kick message that will be used if getResult() != Result.ALLOWED

Returns:
  Current kick message

### setKickMessage

@Deprecated public void setKickMessage(@NotNull @NotNull String message)
Deprecated.
in favour of `kickMessage(net.kyori.adventure.text.Component)`
Sets the kick message to display if getResult() != Result.ALLOWED

Parameters:
  `message` - New kick message

### getHostname

@NotNull public @NotNull String getHostname()
Gets the hostname that the player used to connect to the server, or blank if unknown

Returns:
  The hostname

### allow

public void allow()
Allows the player to log in

### disallow

@Deprecated public void disallow(@NotNull @NotNull PlayerLoginEvent.Result result, @NotNull @NotNull String message)
Deprecated.
in favour of `disallow(Result, net.kyori.adventure.text.Component)`
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 Component message)
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

### getAddress

@NotNull public @NotNull InetAddress getAddress()
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.

### getHandlers

@NotNull public @NotNull HandlerList getHandlers()

Specified by:
  `getHandlers` in class `Event`

### getHandlerList

@NotNull public static @NotNull HandlerList getHandlerList()