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
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPlayerLoginEvent.ResultBasic kick reasons for communicating to plugins -
Field Summary
-
Constructor Summary
Constructors Constructor Description PlayerLoginEvent(Player player)Deprecated.Address should be provided in other constructorPlayerLoginEvent(Player player, java.lang.String hostname)Deprecated.Address should be provided in other constructorPlayerLoginEvent(Player player, java.lang.String hostname, java.net.InetAddress address)PlayerLoginEvent(Player player, java.lang.String hostname, java.net.InetAddress address, java.net.InetAddress realAddress)This constructor defaults message to an empty string, and result to ALLOWEDPlayerLoginEvent(Player player, java.lang.String hostname, java.net.InetAddress address, PlayerLoginEvent.Result result, java.lang.String message, java.net.InetAddress realAddress)This constructor pre-configures the event with a result and messagePlayerLoginEvent(Player player, PlayerLoginEvent.Result result, java.lang.String message)Deprecated.Address and hostname should be provided in other constructor -
Method Summary
Modifier and Type Method Description voidallow()Allows the player to log invoiddisallow(PlayerLoginEvent.Result result, java.lang.String message)Disallows the player from logging in, with the given reasonjava.net.InetAddressgetAddress()Gets theInetAddressfor the Player associated with this event.static HandlerListgetHandlerList()HandlerListgetHandlers()java.lang.StringgetHostname()Gets the hostname that the player used to connect to the server, or blank if unknownjava.lang.StringgetKickMessage()Gets the current kick message that will be used if getResult() != Result.ALLOWEDjava.net.InetAddressgetRealAddress()Gets the connection address of this player, regardless of whether it has been spoofed or not.PlayerLoginEvent.ResultgetResult()Gets the current result of the login, as an enumvoidsetKickMessage(java.lang.String message)Sets the kick message to display if getResult() != Result.ALLOWEDvoidsetResult(PlayerLoginEvent.Result result)Sets the new result of the login, as an enum
-
Constructor Details
-
PlayerLoginEvent
Deprecated.Address should be provided in other constructor- Parameters:
player- ThePlayerfor this event
-
PlayerLoginEvent
Deprecated.Address should be provided in other constructor- Parameters:
player- ThePlayerfor this eventhostname- The hostname that was used to connect to the server
-
PlayerLoginEvent
public PlayerLoginEvent(Player player, java.lang.String hostname, java.net.InetAddress address, java.net.InetAddress realAddress)This constructor defaults message to an empty string, and result to ALLOWED- Parameters:
player- ThePlayerfor this eventhostname- The hostname that was used to connect to the serveraddress- The address the player used to connect, provided for timing issues
-
PlayerLoginEvent
-
PlayerLoginEvent
@Deprecated public PlayerLoginEvent(Player player, PlayerLoginEvent.Result result, java.lang.String message)Deprecated.Address and hostname should be provided in other constructor- Parameters:
player- ThePlayerfor this eventresult- The result status for this eventmessage- The message to be displayed if result denies login
-
PlayerLoginEvent
public PlayerLoginEvent(Player player, java.lang.String hostname, java.net.InetAddress address, PlayerLoginEvent.Result result, java.lang.String message, java.net.InetAddress realAddress)This constructor pre-configures the event with a result and message- Parameters:
player- ThePlayerfor this eventhostname- The hostname that was used to connect to the serveraddress- The address the player used to connect, provided for timing issuesresult- The result status for this eventmessage- The message to be displayed if result denies login
-
-
Method Details
-
getRealAddress
public java.net.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
Gets the current result of the login, as an enum- Returns:
- Current Result of the login
-
setResult
Sets the new result of the login, as an enum- Parameters:
result- New result to set
-
getKickMessage
public java.lang.String getKickMessage()Gets the current kick message that will be used if getResult() != Result.ALLOWED- Returns:
- Current kick message
-
setKickMessage
public void setKickMessage(java.lang.String message)Sets the kick message to display if getResult() != Result.ALLOWED- Parameters:
message- New kick message
-
getHostname
public java.lang.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
Disallows the player from logging in, with the given reason- Parameters:
result- New result for disallowing the playermessage- Kick message to display to the user
-
getAddress
public java.net.InetAddress getAddress()Gets theInetAddressfor 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
- Specified by:
getHandlersin classEvent
-
getHandlerList
-