Class PlayerLoginAttemptEvent
java.lang.Object
fr.fidorial.event.player.PlayerLoginAttemptEvent
- All Implemented Interfaces:
Cancellable, Event
Called when a client attempts to log in.
Listeners can refuse the connection with refuse(Component). This is preferred over
setCancelled(boolean), which does not allow you to say why.
- Since:
- 0.1.0
-
Constructor Summary
ConstructorsConstructorDescriptionPlayerLoginAttemptEvent(PlayerProfile profile, String address, boolean authenticated) Creates an event. -
Method Summary
Modifier and TypeMethodDescriptionaddress()Gets the address the client is connecting from.booleanChecks whether this identity was actually verified.booleanprofile()Gets the identity the client is connecting with.refusal()Gets the reason the connection was refused.voidRefuses the connection, disconnecting the client with the given reason.voidsetCancelled(boolean cancelled) Refuses or re-allows the connection.
-
Constructor Details
-
PlayerLoginAttemptEvent
Creates an event.- Parameters:
profile- the identity the client is connecting withaddress- the client addressauthenticated- whether the identity was verified, rather than derived from a name- Since:
- 0.1.0
-
-
Method Details
-
profile
Gets the identity the client is connecting with.- Returns:
- the profile
- Since:
- 0.1.0
-
address
Gets the address the client is connecting from.When a proxy sits in front of the server, this is the address the proxy forwarded, not the proxy's own.
- Returns:
- the client address
- Since:
- 0.1.0
-
authenticated
public boolean authenticated()Checks whether this identity was actually verified.falsemeans the server is running in offline mode and the uuid was derived from the name the client asked for, so it proves nothing. Treat anything security-sensitive accordingly.- Returns:
trueif the identity was verified- Since:
- 0.1.0
-
refuse
Refuses the connection, disconnecting the client with the given reason.- Parameters:
reason- the message shown to the client- Since:
- 0.1.0
-
refusal
Gets the reason the connection was refused.- Returns:
- the reason, or empty when none was given - including when the event was cancelled
through
setCancelled(boolean) - Since:
- 0.1.0
-
isCancelled
public boolean isCancelled()- Specified by:
isCancelledin interfaceCancellable
-
setCancelled
public void setCancelled(boolean cancelled) Refuses or re-allows the connection.Prefer
refuse(Component), which lets you say why. Re-allowing a connection another listener refused also drops the reason it gave.- Specified by:
setCancelledin interfaceCancellable- Parameters:
cancelled- whether the connection should be refused
-