diff options
author | sk89q <the.sk89q@gmail.com> | 2011-04-16 03:08:13 -0700 |
---|---|---|
committer | sk89q <the.sk89q@gmail.com> | 2011-04-16 03:08:13 -0700 |
commit | 8aa376fc2708db8cb9c21df325174d74b9c7bdb9 (patch) | |
tree | 2d151b0a98ed3642743c6a2d82269d246e4a0496 /src/main/java/net/minecraft/server/ThreadLoginVerifier.java | |
parent | dc6c906e1af84486b1301e788c5b195595119241 (diff) | |
download | craftbukkit-8aa376fc2708db8cb9c21df325174d74b9c7bdb9.tar craftbukkit-8aa376fc2708db8cb9c21df325174d74b9c7bdb9.tar.gz craftbukkit-8aa376fc2708db8cb9c21df325174d74b9c7bdb9.tar.lz craftbukkit-8aa376fc2708db8cb9c21df325174d74b9c7bdb9.tar.xz craftbukkit-8aa376fc2708db8cb9c21df325174d74b9c7bdb9.zip |
Added pre-login event for catching logins right after name verification has completed. This happens in a different thread from the server (and thus can also block).
Diffstat (limited to 'src/main/java/net/minecraft/server/ThreadLoginVerifier.java')
-rw-r--r-- | src/main/java/net/minecraft/server/ThreadLoginVerifier.java | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/main/java/net/minecraft/server/ThreadLoginVerifier.java b/src/main/java/net/minecraft/server/ThreadLoginVerifier.java new file mode 100644 index 00000000..dd6850b7 --- /dev/null +++ b/src/main/java/net/minecraft/server/ThreadLoginVerifier.java @@ -0,0 +1,51 @@ +package net.minecraft.server;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.net.URLEncoder;
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.event.player.PlayerPreLoginEvent;
+
+class ThreadLoginVerifier extends Thread {
+
+ final Packet1Login a;
+
+ final NetLoginHandler b;
+
+ // CraftBukkit start
+ CraftServer server;
+
+ ThreadLoginVerifier(NetLoginHandler netloginhandler, Packet1Login packet1login, CraftServer server) {
+ this.server = server;
+ // CraftBukkit end
+ this.b = netloginhandler;
+ this.a = packet1login;
+ }
+
+ public void run() {
+ try {
+ String s = NetLoginHandler.a(this.b);
+ URL url = new URL("http://www.minecraft.net/game/checkserver.jsp?user=" + URLEncoder.encode(this.a.b, "UTF-8") + "&serverId=" + URLEncoder.encode(s, "UTF-8"));
+ BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(url.openStream()));
+ String s1 = bufferedreader.readLine();
+
+ bufferedreader.close();
+ if (s1.equals("YES")) {
+ PlayerPreLoginEvent event = new PlayerPreLoginEvent(this.a.b, b.getSocket().getInetAddress());
+ server.getPluginManager().callEvent(event);
+
+ if (event.getResult() != PlayerPreLoginEvent.Result.ALLOWED) {
+ this.b.a(event.getKickMessage());
+ return;
+ }
+
+ NetLoginHandler.a(this.b, this.a);
+ } else {
+ this.b.a("Failed to verify username!");
+ }
+ } catch (Exception exception) {
+ exception.printStackTrace();
+ }
+ }
+}
|