Package org.bukkit.event.player
Class PlayerLoginEvent
java.lang.Object
org.bukkit.event.Event
org.bukkit.event.player.PlayerEvent
org.bukkit.event.player.PlayerLoginEvent
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
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
Modifier and TypeClassDescriptionstatic enum
Basic kick reasons for communicating to plugins -
Field Summary
Fields inherited from class org.bukkit.event.player.PlayerEvent
player
-
Constructor Summary
ConstructorDescriptionPlayerLoginEvent
(Player player, String hostname, InetAddress address) PlayerLoginEvent
(Player player, String hostname, InetAddress address, InetAddress realAddress) This constructor defaults message to an empty string, and result to ALLOWEDPlayerLoginEvent
(Player player, String hostname, InetAddress address, PlayerLoginEvent.Result result, String message, InetAddress realAddress) This constructor pre-configures the event with a result and message -
Method Summary
Modifier and TypeMethodDescriptionvoid
allow()
Allows the player to log invoid
disallow
(PlayerLoginEvent.Result result, String message) Disallows the player from logging in, with the given reasonGets theInetAddress
for the Player associated with this event.static HandlerList
Gets the hostname that the player used to connect to the server, or blank if unknownGets the current kick message that will be used if getResult() != Result.ALLOWEDGets the connection address of this player, regardless of whether it has been spoofed or not.Gets the current result of the login, as an enumvoid
setKickMessage
(String message) Sets the kick message to display if getResult() != Result.ALLOWEDvoid
setResult
(PlayerLoginEvent.Result result) Sets the new result of the login, as an enumMethods inherited from class org.bukkit.event.player.PlayerEvent
getPlayer
Methods inherited from class org.bukkit.event.Event
getEventName, isAsynchronous
-
Constructor Details
-
PlayerLoginEvent
public 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- Parameters:
player
- ThePlayer
for this eventhostname
- The hostname that was used to connect to the serveraddress
- The address the player used to connect, provided for timing issuesrealAddress
- the actual, unspoofed connecting address
-
PlayerLoginEvent
-
PlayerLoginEvent
public PlayerLoginEvent(@NotNull Player player, @NotNull String hostname, @NotNull InetAddress address, @NotNull PlayerLoginEvent.Result result, @NotNull String message, @NotNull InetAddress realAddress) This constructor pre-configures the event with a result and message- Parameters:
player
- ThePlayer
for 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 loginrealAddress
- the actual, unspoofed connecting address
-
-
Method Details
-
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
Gets the current kick message that will be used if getResult() != Result.ALLOWED- Returns:
- Current kick message
-
setKickMessage
Sets the kick message to display if getResult() != Result.ALLOWED- Parameters:
message
- New kick message
-
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
Gets theInetAddress
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
- Specified by:
getHandlers
in classEvent
-
getHandlerList
-