3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-16 21:10:17 +01:00
Paper/CraftBukkit-Patches/0053-Always-Fire-PreLoginEvent.patch

72 Zeilen
3.8 KiB
Diff

2013-09-08 00:36:30 +02:00
From d0d33c2a76ff2f3296819e8285c903de0c5f3904 Mon Sep 17 00:00:00 2001
2013-06-25 10:09:55 +02:00
From: md_5 <md_5@live.com.au>
Date: Tue, 25 Jun 2013 18:09:26 +1000
Subject: [PATCH] Always Fire PreLoginEvent
diff --git a/src/main/java/net/minecraft/server/PendingConnection.java b/src/main/java/net/minecraft/server/PendingConnection.java
2013-09-08 00:36:30 +02:00
index 9deb9d1..a5c3104 100644
2013-06-25 10:09:55 +02:00
--- a/src/main/java/net/minecraft/server/PendingConnection.java
+++ b/src/main/java/net/minecraft/server/PendingConnection.java
2013-09-08 00:36:30 +02:00
@@ -114,7 +114,7 @@ public class PendingConnection extends Connection {
2013-07-02 05:03:56 +02:00
}
2013-06-25 10:09:55 +02:00
2013-07-02 05:03:56 +02:00
this.j = true;
2013-06-25 10:09:55 +02:00
- if (this.server.getOnlineMode()) {
+ if (true) { // Spigot - Always fire
2013-07-02 05:03:56 +02:00
(new ThreadLoginVerifier(this, server.server)).start(); // CraftBukkit - add CraftServer
} else {
this.h = true;
2013-06-25 10:09:55 +02:00
diff --git a/src/main/java/net/minecraft/server/ThreadLoginVerifier.java b/src/main/java/net/minecraft/server/ThreadLoginVerifier.java
2013-07-02 05:03:56 +02:00
index 5e45cae..70f9fea 100644
2013-06-25 10:09:55 +02:00
--- a/src/main/java/net/minecraft/server/ThreadLoginVerifier.java
+++ b/src/main/java/net/minecraft/server/ThreadLoginVerifier.java
@@ -27,24 +27,29 @@ class ThreadLoginVerifier extends Thread {
this.pendingConnection = pendingconnection;
}
+ private boolean auth() throws java.io.IOException {
2013-07-02 05:03:56 +02:00
+ String s = (new BigInteger(MinecraftEncryption.a(PendingConnection.a(this.pendingConnection), PendingConnection.b(this.pendingConnection).H().getPublic(), PendingConnection.c(this.pendingConnection)))).toString(16);
2013-06-25 10:09:55 +02:00
+ URL url = new URL("http://session.minecraft.net/game/checkserver.jsp?user=" + URLEncoder.encode(PendingConnection.d(this.pendingConnection), "UTF-8") + "&serverId=" + URLEncoder.encode(s, "UTF-8"));
2013-07-02 05:03:56 +02:00
+ BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(url.openConnection(PendingConnection.b(this.pendingConnection).ap()).getInputStream()));
2013-06-25 10:09:55 +02:00
+ String s1 = bufferedreader.readLine();
+
+ bufferedreader.close();
+ if (!"YES".equals(s1)) {
+ this.pendingConnection.disconnect("Failed to verify username!");
+ return false;
+ }
+
+ // CraftBukkit start
+ if (this.pendingConnection.getSocket() == null) {
+ return false;
+ }
+ return true;
+ }
+
public void run() {
try {
if (org.spigotmc.SpamHaus.filterIp(pendingConnection)) return; // Spigot
2013-07-02 05:03:56 +02:00
- String s = (new BigInteger(MinecraftEncryption.a(PendingConnection.a(this.pendingConnection), PendingConnection.b(this.pendingConnection).H().getPublic(), PendingConnection.c(this.pendingConnection)))).toString(16);
2013-06-25 10:09:55 +02:00
- URL url = new URL("http://session.minecraft.net/game/checkserver.jsp?user=" + URLEncoder.encode(PendingConnection.d(this.pendingConnection), "UTF-8") + "&serverId=" + URLEncoder.encode(s, "UTF-8"));
2013-07-02 05:03:56 +02:00
- BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(url.openConnection(PendingConnection.b(this.pendingConnection).ap()).getInputStream()));
2013-06-25 10:09:55 +02:00
- String s1 = bufferedreader.readLine();
-
- bufferedreader.close();
- if (!"YES".equals(s1)) {
- this.pendingConnection.disconnect("Failed to verify username!");
- return;
- }
-
- // CraftBukkit start
- if (this.pendingConnection.getSocket() == null) {
- return;
- }
+ if (server.getOnlineMode() && !auth()) return; // Spigot
AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(PendingConnection.d(this.pendingConnection), ((java.net.InetSocketAddress) this.pendingConnection.networkManager.getSocketAddress()).getAddress()); // Spigot
this.server.getPluginManager().callEvent(asyncEvent);
--
1.8.1.2