summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorWesley Wolfe <weswolf@aol.com>2012-03-19 03:59:22 -0500
committerWesley Wolfe <weswolf@aol.com>2012-06-13 23:01:03 -0500
commit8c689135063b7cda25b06de8c780f5e812754ee2 (patch)
tree65b561581881aa43e2115f69d156ccbef346c8c7 /src/main
parent9e73a8887c5f142abbc7a324df17d167b2427478 (diff)
downloadbukkit-8c689135063b7cda25b06de8c780f5e812754ee2.tar
bukkit-8c689135063b7cda25b06de8c780f5e812754ee2.tar.gz
bukkit-8c689135063b7cda25b06de8c780f5e812754ee2.tar.lz
bukkit-8c689135063b7cda25b06de8c780f5e812754ee2.tar.xz
bukkit-8c689135063b7cda25b06de8c780f5e812754ee2.zip
Add asynchronous pre-login event; Addresses BUKKIT-1213
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java108
1 files changed, 108 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java b/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java
new file mode 100644
index 00000000..f7bc490d
--- /dev/null
+++ b/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java
@@ -0,0 +1,108 @@
+package org.bukkit.event.player;
+
+import java.net.InetAddress;
+
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+
+/**
+ * Stores details for players attempting to log in.<br>
+ * This event is asynchronous, and not run using main thread.
+ */
+public class AsyncPlayerPreLoginEvent extends Event {
+ private static final HandlerList handlers = new HandlerList();
+ private PlayerPreLoginEvent.Result result;
+ private String message;
+ private final String name;
+ private final InetAddress ipAddress;
+
+ public AsyncPlayerPreLoginEvent(final String name, final InetAddress ipAddress) {
+ super(true);
+ this.result = PlayerPreLoginEvent.Result.ALLOWED;
+ this.message = "";
+ this.name = name;
+ this.ipAddress = ipAddress;
+ }
+
+ /**
+ * Gets the current result of the login, as an enum
+ *
+ * @return Current Result of the login
+ */
+ public PlayerPreLoginEvent.Result getResult() {
+ return result;
+ }
+
+ /**
+ * Sets the new result of the login, as an enum
+ *
+ * @param result New result to set
+ */
+ public void setResult(final PlayerPreLoginEvent.Result result) {
+ this.result = result;
+ }
+
+ /**
+ * Gets the current kick message that will be used if getResult() != Result.ALLOWED
+ *
+ * @return Current kick message
+ */
+ public String getKickMessage() {
+ return message;
+ }
+
+ /**
+ * Sets the kick message to display if getResult() != Result.ALLOWED
+ *
+ * @param message New kick message
+ */
+ public void setKickMessage(final String message) {
+ this.message = message;
+ }
+
+ /**
+ * Allows the player to log in
+ */
+ public void allow() {
+ result = PlayerPreLoginEvent.Result.ALLOWED;
+ message = "";
+ }
+
+ /**
+ * Disallows the player from logging in, with the given reason
+ *
+ * @param result New result for disallowing the player
+ * @param message Kick message to display to the user
+ */
+ public void disallow(final PlayerPreLoginEvent.Result result, final String message) {
+ this.result = result;
+ this.message = message;
+ }
+
+ /**
+ * Gets the player's name.
+ *
+ * @return the player's name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Gets the player IP address.
+ *
+ * @return The IP address
+ */
+ public InetAddress getAddress() {
+ return ipAddress;
+ }
+
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}