mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-16 06:30:46 +01:00
Add PlayerLoginEvent#getRealAddress
Adapted from Spigot commit 05db99ce17
.
By: md_5 <git@md-5.net>
This commit is contained in:
parent
9ce011cf3b
commit
804a80b327
1 changed files with 32 additions and 3 deletions
|
@ -15,6 +15,7 @@ import org.jetbrains.annotations.NotNull;
|
|||
public class PlayerLoginEvent extends PlayerEvent {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final InetAddress address;
|
||||
private final InetAddress realAddress;
|
||||
private final String hostname;
|
||||
private Result result = Result.ALLOWED;
|
||||
private String message = "";
|
||||
|
@ -27,11 +28,26 @@ public class PlayerLoginEvent extends PlayerEvent {
|
|||
* @param hostname The hostname that was used to connect to the server
|
||||
* @param address The address the player used to connect, provided for
|
||||
* timing issues
|
||||
* @param realAddress the actual, unspoofed connecting address
|
||||
*/
|
||||
public PlayerLoginEvent(@NotNull final Player player, @NotNull final String hostname, @NotNull final InetAddress address) {
|
||||
public PlayerLoginEvent(@NotNull final Player player, @NotNull final String hostname, @NotNull final InetAddress address, final @NotNull InetAddress realAddress) {
|
||||
super(player);
|
||||
this.hostname = hostname;
|
||||
this.address = address;
|
||||
this.realAddress = realAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructor defaults message to an empty string, and result to
|
||||
* ALLOWED
|
||||
*
|
||||
* @param player The {@link Player} for this event
|
||||
* @param hostname The hostname that was used to connect to the server
|
||||
* @param address The address the player used to connect, provided for
|
||||
* timing issues
|
||||
*/
|
||||
public PlayerLoginEvent(@NotNull final Player player, @NotNull final String hostname, @NotNull final InetAddress address) {
|
||||
this(player, hostname, address, address);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -43,9 +59,10 @@ public class PlayerLoginEvent extends PlayerEvent {
|
|||
* timing issues
|
||||
* @param result The result status for this event
|
||||
* @param message The message to be displayed if result denies login
|
||||
* @param realAddress the actual, unspoofed connecting address
|
||||
*/
|
||||
public PlayerLoginEvent(@NotNull final Player player, @NotNull String hostname, @NotNull final InetAddress address, @NotNull final Result result, @NotNull final String message) {
|
||||
this(player, hostname, address);
|
||||
public PlayerLoginEvent(@NotNull final Player player, @NotNull String hostname, @NotNull final InetAddress address, @NotNull final Result result, @NotNull final String message, @NotNull final InetAddress realAddress) {
|
||||
this(player, hostname, address, realAddress);
|
||||
this.result = result;
|
||||
this.message = message;
|
||||
}
|
||||
|
@ -132,6 +149,18 @@ public class PlayerLoginEvent extends PlayerEvent {
|
|||
return address;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the connection address of this player, regardless of whether it has
|
||||
* been spoofed or not.
|
||||
*
|
||||
* @return the player's connection address
|
||||
* @see #getAddress()
|
||||
*/
|
||||
@NotNull
|
||||
public InetAddress getRealAddress() {
|
||||
return realAddress;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
|
|
Loading…
Reference in a new issue