mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-06 10:49:40 +01:00
131 lines
6.2 KiB
Diff
131 lines
6.2 KiB
Diff
From 9ec255571174d13504b89b03e0625ec93ae1291b Mon Sep 17 00:00:00 2001
|
|
From: md_5 <git@md-5.net>
|
|
Date: Wed, 18 Dec 2013 13:32:10 +1100
|
|
Subject: [PATCH] Fire PreLogin Events in Offline Mode
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/LoginListener.java b/src/main/java/net/minecraft/server/LoginListener.java
|
|
index aa06e92..fa80b74 100644
|
|
--- a/src/main/java/net/minecraft/server/LoginListener.java
|
|
+++ b/src/main/java/net/minecraft/server/LoginListener.java
|
|
@@ -108,7 +108,7 @@ public class LoginListener implements PacketLoginInListener {
|
|
this.g = EnumProtocolState.KEY;
|
|
this.networkManager.handle(new PacketLoginOutEncryptionBegin(this.j, this.server.I().getPublic(), this.e), new GenericFutureListener[0]);
|
|
} else {
|
|
- this.g = EnumProtocolState.READY_TO_ACCEPT;
|
|
+ (new ThreadPlayerLookupUUID(this, "User Authenticator #" + b.incrementAndGet())).start(); // Spigot
|
|
}
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/ThreadPlayerLookupUUID.java b/src/main/java/net/minecraft/server/ThreadPlayerLookupUUID.java
|
|
index cc96775..ea8c269 100644
|
|
--- a/src/main/java/net/minecraft/server/ThreadPlayerLookupUUID.java
|
|
+++ b/src/main/java/net/minecraft/server/ThreadPlayerLookupUUID.java
|
|
@@ -22,47 +22,21 @@ class ThreadPlayerLookupUUID extends Thread {
|
|
|
|
public void run() {
|
|
try {
|
|
+ // Spigot Start
|
|
+ if ( !LoginListener.b( this.a ).getOnlineMode() )
|
|
+ {
|
|
+ fireLoginEvents();
|
|
+ LoginListener.a(this.a, EnumProtocolState.READY_TO_ACCEPT);
|
|
+ return;
|
|
+ }
|
|
+ // Spigot End
|
|
String s = (new BigInteger(MinecraftEncryption.a(LoginListener.a(this.a), LoginListener.b(this.a).I().getPublic(), LoginListener.c(this.a)))).toString(16);
|
|
|
|
LoginListener.a(this.a, LoginListener.b(this.a).as().hasJoinedServer(new GameProfile((String) null, LoginListener.d(this.a).getName()), s));
|
|
if (LoginListener.d(this.a) != null) {
|
|
- // CraftBukkit start
|
|
- if (!this.a.networkManager.d()) {
|
|
- return;
|
|
- }
|
|
-
|
|
- String playerName = LoginListener.d(this.a).getName();
|
|
- java.net.InetAddress address = ((java.net.InetSocketAddress) a.networkManager.getSocketAddress()).getAddress();
|
|
- final org.bukkit.craftbukkit.CraftServer server = LoginListener.b(this.a).server;
|
|
-
|
|
- AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address);
|
|
- server.getPluginManager().callEvent(asyncEvent);
|
|
-
|
|
- if (PlayerPreLoginEvent.getHandlerList().getRegisteredListeners().length != 0) {
|
|
- final PlayerPreLoginEvent event = new PlayerPreLoginEvent(playerName, address);
|
|
- if (asyncEvent.getResult() != PlayerPreLoginEvent.Result.ALLOWED) {
|
|
- event.disallow(asyncEvent.getResult(), asyncEvent.getKickMessage());
|
|
- }
|
|
- Waitable<PlayerPreLoginEvent.Result> waitable = new Waitable<PlayerPreLoginEvent.Result>() {
|
|
- @Override
|
|
- protected PlayerPreLoginEvent.Result evaluate() {
|
|
- server.getPluginManager().callEvent(event);
|
|
- return event.getResult();
|
|
- }};
|
|
-
|
|
- LoginListener.b(this.a).processQueue.add(waitable);
|
|
- if (waitable.get() != PlayerPreLoginEvent.Result.ALLOWED) {
|
|
- this.a.disconnect(event.getKickMessage());
|
|
- return;
|
|
- }
|
|
- } else {
|
|
- if (asyncEvent.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) {
|
|
- this.a.disconnect(asyncEvent.getKickMessage());
|
|
- return;
|
|
- }
|
|
- }
|
|
- // CraftBukkit end
|
|
-
|
|
+ // Spigot Start
|
|
+ fireLoginEvents();
|
|
+ // Spigot End
|
|
LoginListener.e().info("UUID of player " + LoginListener.d(this.a).getName() + " is " + LoginListener.d(this.a).getId());
|
|
LoginListener.a(this.a, EnumProtocolState.READY_TO_ACCEPT);
|
|
} else {
|
|
@@ -79,4 +53,44 @@ class ThreadPlayerLookupUUID extends Thread {
|
|
// CraftBukkit end
|
|
}
|
|
}
|
|
+
|
|
+ private void fireLoginEvents() throws Exception
|
|
+ {
|
|
+ // CraftBukkit start
|
|
+ if (!this.a.networkManager.d()) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ String playerName = LoginListener.d(this.a).getName();
|
|
+ java.net.InetAddress address = ((java.net.InetSocketAddress) a.networkManager.getSocketAddress()).getAddress();
|
|
+ final org.bukkit.craftbukkit.CraftServer server = LoginListener.b(this.a).server;
|
|
+
|
|
+ AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address);
|
|
+ server.getPluginManager().callEvent(asyncEvent);
|
|
+
|
|
+ if (PlayerPreLoginEvent.getHandlerList().getRegisteredListeners().length != 0) {
|
|
+ final PlayerPreLoginEvent event = new PlayerPreLoginEvent(playerName, address);
|
|
+ if (asyncEvent.getResult() != PlayerPreLoginEvent.Result.ALLOWED) {
|
|
+ event.disallow(asyncEvent.getResult(), asyncEvent.getKickMessage());
|
|
+ }
|
|
+ Waitable<PlayerPreLoginEvent.Result> waitable = new Waitable<PlayerPreLoginEvent.Result>() {
|
|
+ @Override
|
|
+ protected PlayerPreLoginEvent.Result evaluate() {
|
|
+ server.getPluginManager().callEvent(event);
|
|
+ return event.getResult();
|
|
+ }};
|
|
+
|
|
+ LoginListener.b(this.a).processQueue.add(waitable);
|
|
+ if (waitable.get() != PlayerPreLoginEvent.Result.ALLOWED) {
|
|
+ this.a.disconnect(event.getKickMessage());
|
|
+ return;
|
|
+ }
|
|
+ } else {
|
|
+ if (asyncEvent.getLoginResult() != AsyncPlayerPreLoginEvent.Result.ALLOWED) {
|
|
+ this.a.disconnect(asyncEvent.getKickMessage());
|
|
+ return;
|
|
+ }
|
|
+ }
|
|
+ // CraftBukkit end
|
|
+ }
|
|
}
|
|
--
|
|
1.8.3.2
|
|
|