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
Nested ClassesModifier and TypeClassDescriptionstatic enum
Basic kick reasons for communicating to plugins -
Field Summary
Fields inherited from class org.bukkit.event.player.PlayerEvent
player
-
Constructor Summary
ConstructorsConstructorDescriptionPlayerLoginEvent
(@NotNull Player player, @NotNull String hostname, @NotNull InetAddress address) PlayerLoginEvent
(@NotNull Player player, @NotNull String hostname, @NotNull InetAddress address, @NotNull InetAddress realAddress) PlayerLoginEvent
(@NotNull Player player, @NotNull String hostname, @NotNull InetAddress address, @NotNull PlayerLoginEvent.Result result, @NotNull String message, @NotNull InetAddress realAddress) Deprecated, for removal: This API element is subject to removal in a future version.PlayerLoginEvent
(@NotNull Player player, @NotNull String hostname, @NotNull InetAddress address, @NotNull PlayerLoginEvent.Result result, Component message, @NotNull InetAddress realAddress) -
Method Summary
Modifier and TypeMethodDescriptionvoid
allow()
Allows the player to log invoid
disallow
(@NotNull PlayerLoginEvent.Result result, @NotNull String message) Deprecated.void
disallow
(@NotNull PlayerLoginEvent.Result result, @NotNull Component message) Disallows the player from logging in, with the given reasonGets theInetAddress
for the Player associated with this event.static @NotNull HandlerList
Gets the hostname that the player used to connect to the server, or blank if unknownDeprecated.in favour ofkickMessage()
Gets the connection address of this player, regardless of whether it has been spoofed or not.Gets the current result of the login, as an enumGets the current kick message that will be used when the outcome is not allowedvoid
kickMessage
(@NotNull Component message) Sets the kick message to display when the outcome is not allowedvoid
setKickMessage
(@NotNull String message) Deprecated.in favour ofkickMessage(Component)
void
setResult
(@NotNull 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
callEvent, getEventName, isAsynchronous
-
Constructor Details
-
PlayerLoginEvent
-
PlayerLoginEvent
-
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
-
-
Method Details
-
getHostname
Gets the hostname that the player used to connect to the server, or blank if unknown- Returns:
- The hostname
-
getAddress
Gets theInetAddress
for the Player associated with this event. This method is provided as a workaround for player.getAddress() returningnull
during PlayerLoginEvent.- Returns:
- The address for this player. For legacy compatibility, this may
be
null
.
-
getRealAddress
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
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
-
kickMessage
Gets the current kick message that will be used when the outcome is not allowed- Returns:
- Current kick message
-
kickMessage
Sets the kick message to display when the outcome is not allowed- Parameters:
message
- New kick message
-
getKickMessage
Deprecated.in favour ofkickMessage()
Gets the current kick message that will be used when the outcome is not allowed- Returns:
- Current kick message
-
setKickMessage
Deprecated.in favour ofkickMessage(Component)
Sets the kick message to display when the outcome is not allowed- Parameters:
message
- New kick message
-
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 ofdisallow(Result, Component)
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
-
disallow
public void disallow(@NotNull @NotNull PlayerLoginEvent.Result result, @NotNull @NotNull Component message) 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
-
getHandlers
- Specified by:
getHandlers
in classEvent
-
getHandlerList
-
disallow(Result, Component)