Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 20:40:08 +01:00
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).
Dieser Commit ist enthalten in:
Ursprung
dc6c906e1a
Commit
8aa376fc27
@ -22,6 +22,12 @@ public class NetLoginHandler extends NetHandler {
|
|||||||
this.b.d = 0;
|
this.b.d = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CraftBukkit start
|
||||||
|
public Socket getSocket() {
|
||||||
|
return b.f;
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
public void a() {
|
public void a() {
|
||||||
if (this.h != null) {
|
if (this.h != null) {
|
||||||
this.b(this.h);
|
this.b(this.h);
|
||||||
@ -67,7 +73,7 @@ public class NetLoginHandler extends NetHandler {
|
|||||||
if (!this.e.l) {
|
if (!this.e.l) {
|
||||||
this.b(packet1login);
|
this.b(packet1login);
|
||||||
} else {
|
} else {
|
||||||
(new ThreadLoginVerifier(this, packet1login)).start();
|
(new ThreadLoginVerifier(this, packet1login, e.server)).start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ public class NetworkManager {
|
|||||||
public static int b;
|
public static int b;
|
||||||
public static int c;
|
public static int c;
|
||||||
private Object e = new Object();
|
private Object e = new Object();
|
||||||
private Socket f;
|
public Socket f; // CraftBukkit private->public
|
||||||
private final SocketAddress g;
|
private final SocketAddress g;
|
||||||
private DataInputStream h;
|
private DataInputStream h;
|
||||||
private DataOutputStream i;
|
private DataOutputStream i;
|
||||||
|
51
src/main/java/net/minecraft/server/ThreadLoginVerifier.java
Normale Datei
51
src/main/java/net/minecraft/server/ThreadLoginVerifier.java
Normale Datei
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren