Class KickedFromServerEvent
java.lang.Object
com.velocitypowered.api.event.player.KickedFromServerEvent
- All Implemented Interfaces:
ResultedEvent<KickedFromServerEvent.ServerKickResult>
@AwaitingEvent
public final class KickedFromServerEvent
extends Object
implements ResultedEvent<KickedFromServerEvent.ServerKickResult>
Fired when a player is kicked from a server. You may either allow Velocity to kick the player
(with an optional reason override) or redirect the player to a separate server. By default,
Velocity will notify the user (if they are already connected to a server) or disconnect them
(if they are not on a server and no other servers are available). Velocity will wait on this
event to finish firing before taking the specified action.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Tells the proxy to disconnect the player with the specified reason.static final class
Notifies the player with the specified message but does nothing else.static final class
Tells the proxy to redirect the player to another server.static interface
Represents the base interface forKickedFromServerEvent
results.Nested classes/interfaces inherited from interface com.velocitypowered.api.event.ResultedEvent
ResultedEvent.ComponentResult, ResultedEvent.GenericResult, ResultedEvent.Result
-
Constructor Summary
ConstructorDescriptionKickedFromServerEvent
(Player player, RegisteredServer server, @Nullable Component originalReason, boolean duringServerConnect, KickedFromServerEvent.ServerKickResult result) Creates aKickedFromServerEvent
instance. -
Method Summary
Modifier and TypeMethodDescription@NonNull Player
The player who has been kicked out.Returns the result associated with this event.@NonNull RegisteredServer
The server from which the player has been kicked.The reason why the player was kicked, the server may or may not provide this reason.boolean
Deprecated.boolean
Returns whether or not the player got kicked while connecting to another server.void
setResult
(@NonNull KickedFromServerEvent.ServerKickResult result) Sets the result of this event.
-
Constructor Details
-
KickedFromServerEvent
public KickedFromServerEvent(Player player, RegisteredServer server, @Nullable Component originalReason, boolean duringServerConnect, KickedFromServerEvent.ServerKickResult result) Creates aKickedFromServerEvent
instance.- Parameters:
player
- the player affectedserver
- the server the player disconnected fromoriginalReason
- the reason for being kicked, optionalduringServerConnect
- whether or not the player was kicked during the connection processresult
- the initial result
-
-
Method Details
-
getResult
Description copied from interface:ResultedEvent
Returns the result associated with this event.- Specified by:
getResult
in interfaceResultedEvent<KickedFromServerEvent.ServerKickResult>
- Returns:
- the result of this event
-
setResult
Description copied from interface:ResultedEvent
Sets the result of this event. The result must be non-null.- Specified by:
setResult
in interfaceResultedEvent<KickedFromServerEvent.ServerKickResult>
- Parameters:
result
- the new result
-
getPlayer
The player who has been kicked out.- Returns:
- the player affected
-
getServer
The server from which the player has been kicked.- Returns:
- the server the player disconnected from
-
getServerKickReason
The reason why the player was kicked, the server may or may not provide this reason.- Returns:
- the reason for being kicked, optional
-
kickedDuringServerConnect
public boolean kickedDuringServerConnect()Returns whether or not the player got kicked while connecting to another server.- Returns:
- whether or not the player got kicked
-
kickedDuringLogin
Deprecated.kickedDuringServerConnect()
has a better name and reflects the actual resultReturns whether or not the player got kicked while logging in.- Returns:
- whether or not the player got kicked
-
kickedDuringServerConnect()
has a better name and reflects the actual result