summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authorWesley Wolfe <weswolf@aol.com>2012-04-03 17:00:05 -0500
committerWesley Wolfe <weswolf@aol.com>2012-04-03 17:00:05 -0500
commit9030ba5f99433ba38180ae88b1510da2f92a0203 (patch)
tree3705ba10a8999c5f2b79cdccd3c3d6b0c5e6b9e3 /src/main/java/org
parentea8de14db27ba621574a477e727028423ced16e2 (diff)
downloadbukkit-9030ba5f99433ba38180ae88b1510da2f92a0203.tar
bukkit-9030ba5f99433ba38180ae88b1510da2f92a0203.tar.gz
bukkit-9030ba5f99433ba38180ae88b1510da2f92a0203.tar.lz
bukkit-9030ba5f99433ba38180ae88b1510da2f92a0203.tar.xz
bukkit-9030ba5f99433ba38180ae88b1510da2f92a0203.zip
Adds address to PlayerLoginEvent; Addresses BUKKIT-431
This also deprecates old constructors left for compatibility. Address will default to null in these cases.
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/bukkit/event/player/PlayerLoginEvent.java60
1 files changed, 56 insertions, 4 deletions
diff --git a/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java b/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java
index 2a457da1..60c08756 100644
--- a/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java
@@ -1,5 +1,7 @@
package org.bukkit.event.player;
+import java.net.InetAddress;
+
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
@@ -8,21 +10,59 @@ import org.bukkit.event.HandlerList;
*/
public class PlayerLoginEvent extends PlayerEvent {
private static final HandlerList handlers = new HandlerList();
+ private final InetAddress address;
+ private final String hostname;
private Result result = Result.ALLOWED;
private String message = "";
- private String hostname = "";
+ /**
+ * @deprecated Address should be provided in other constructor
+ */
+ @Deprecated
public PlayerLoginEvent(final Player player) {
- super(player);
+ this(player, "", null);
}
+ /**
+ * @deprecated Address should be provided in other constructor
+ */
+ @Deprecated
public PlayerLoginEvent(final Player player, final String hostname) {
- this(player);
+ this(player, hostname, null);
+ }
+
+ /**
+ * 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(final Player player, final String hostname, final InetAddress address) {
+ super(player);
this.hostname = hostname;
+ this.address = address;
}
+ /**
+ * @deprecated Address and hostname should be provided in other constructor
+ */
+ @Deprecated
public PlayerLoginEvent(final Player player, final Result result, final String message) {
- this(player);
+ this(player, "", null, result, message);
+ }
+
+ /**
+ * This constructor pre-configures the event with a result and message
+ *
+ * @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
+ * @param result The result status for this event
+ * @param message The message to be displayed if result denies login
+ */
+ public PlayerLoginEvent(final Player player, String hostname, final InetAddress address, final Result result, final String message) {
+ this(player, hostname, address);
this.result = result;
this.message = message;
}
@@ -91,6 +131,18 @@ public class PlayerLoginEvent extends PlayerEvent {
this.message = message;
}
+ /**
+ * Gets the {@link InetAddress} for the Player associated
+ * with this event. This method is provided as a workaround for
+ * player.getAddress() returning null during PlayerLoginEvent.
+ *
+ * @return The address for this player. For legacy compatibility,
+ * this may be null.
+ */
+ public InetAddress getAddress() {
+ return address;
+ }
+
@Override
public HandlerList getHandlers() {
return handlers;