2015-01-05 04:32:01 +01:00
From a31599ba0f5d0464336c4447f4e7a0b8f681003b Mon Sep 17 00:00:00 2001
2014-07-21 22:46:54 +02:00
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
2014-11-28 02:17:45 +01:00
index ba2b912..a59ea80 100644
2014-07-21 22:46:54 +02:00
--- a/src/main/java/net/minecraft/server/LoginListener.java
+++ b/src/main/java/net/minecraft/server/LoginListener.java
2014-11-28 02:17:45 +01:00
@@ -60,10 +60,23 @@ public class LoginListener implements PacketLoginInListener, IUpdatePlayerListBo
2014-07-21 22:46:54 +02:00
}
+ // Spigot start
+ public void initUUID()
+ {
+ UUID uuid = UUID.nameUUIDFromBytes( ( "OfflinePlayer:" + this.i.getName() ).getBytes( Charsets.UTF_8 ) );
+
+ this.i = new GameProfile( uuid, this.i.getName() );
+ }
+ // Spigot end
+
2014-11-28 02:17:45 +01:00
public void b() {
2014-07-21 22:46:54 +02:00
+ // Spigot start - Moved to initUUID
+ /*
if (!this.i.isComplete()) {
this.i = this.a(this.i);
}
+ */
+ // Spigot end
// CraftBukkit start - fire PlayerLoginEvent
2014-11-28 02:17:45 +01:00
EntityPlayer s = this.server.getPlayerList().attemptLogin(this, this.i, hostname);
@@ -98,7 +111,7 @@ public class LoginListener implements PacketLoginInListener, IUpdatePlayerListBo
2014-07-21 22:46:54 +02:00
this.g = EnumProtocolState.KEY;
2014-11-28 02:17:45 +01:00
this.networkManager.handle(new PacketLoginOutEncryptionBegin(this.j, this.server.P().getPublic(), this.e));
2014-07-21 22:46:54 +02:00
} else {
- this.g = EnumProtocolState.READY_TO_ACCEPT;
+ (new ThreadPlayerLookupUUID(this, "User Authenticator #" + b.incrementAndGet())).start(); // Spigot
}
2014-11-28 02:17:45 +01:00
}
2014-07-21 22:46:54 +02:00
diff --git a/src/main/java/net/minecraft/server/ThreadPlayerLookupUUID.java b/src/main/java/net/minecraft/server/ThreadPlayerLookupUUID.java
2014-11-28 02:17:45 +01:00
index bbceef0..8b93fd5 100644
2014-07-21 22:46:54 +02:00
--- a/src/main/java/net/minecraft/server/ThreadPlayerLookupUUID.java
+++ b/src/main/java/net/minecraft/server/ThreadPlayerLookupUUID.java
2014-11-28 02:17:45 +01:00
@@ -24,50 +24,19 @@ class ThreadPlayerLookupUUID extends Thread {
GameProfile gameprofile = LoginListener.b(this.a);
2014-07-21 22:46:54 +02:00
try {
+ // Spigot Start
2014-11-28 02:17:45 +01:00
+ if ( !LoginListener.a( this.a ).getOnlineMode() )
2014-07-21 22:46:54 +02:00
+ {
+ a.initUUID();
+ fireLoginEvents();
+ return;
+ }
+ // Spigot End
2014-11-28 02:17:45 +01:00
String s = (new BigInteger(MinecraftEncryption.a(LoginListener.c(this.a), LoginListener.a(this.a).P().getPublic(), LoginListener.d(this.a)))).toString(16);
2014-07-21 22:46:54 +02:00
2014-11-28 02:17:45 +01:00
LoginListener.a(this.a, LoginListener.a(this.a).aB().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s));
if (LoginListener.b(this.a) != null) {
2014-07-21 22:46:54 +02:00
- // CraftBukkit start - fire PlayerPreLoginEvent
2014-11-28 02:17:45 +01:00
- if (!this.a.networkManager.g()) {
2014-07-21 22:46:54 +02:00
- return;
- }
-
2014-11-28 02:17:45 +01:00
- String playerName = LoginListener.b(this.a).getName();
2014-07-21 22:46:54 +02:00
- java.net.InetAddress address = ((java.net.InetSocketAddress) a.networkManager.getSocketAddress()).getAddress();
2014-11-28 02:17:45 +01:00
- java.util.UUID uniqueId = LoginListener.b(this.a).getId();
- final org.bukkit.craftbukkit.CraftServer server = LoginListener.a(this.a).server;
2014-07-21 22:46:54 +02:00
-
- AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId);
- server.getPluginManager().callEvent(asyncEvent);
-
- if (PlayerPreLoginEvent.getHandlerList().getRegisteredListeners().length != 0) {
- final PlayerPreLoginEvent event = new PlayerPreLoginEvent(playerName, address, uniqueId);
- 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();
- }};
-
2014-11-28 02:17:45 +01:00
- LoginListener.a(this.a).processQueue.add(waitable);
2014-07-21 22:46:54 +02:00
- 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
2014-11-28 02:17:45 +01:00
-
- LoginListener.e().info("UUID of player " + LoginListener.b(this.a).getName() + " is " + LoginListener.b(this.a).getId());
2014-07-21 22:46:54 +02:00
- LoginListener.a(this.a, EnumProtocolState.READY_TO_ACCEPT);
+ fireLoginEvents(); // Spigot
2014-11-28 02:17:45 +01:00
} else if (LoginListener.a(this.a).S()) {
2014-07-21 22:46:54 +02:00
LoginListener.e().warn("Failed to verify username but will let them in anyway!");
LoginListener.a(this.a, this.a.a(gameprofile));
@@ -93,4 +62,48 @@ class ThreadPlayerLookupUUID extends Thread {
}
2014-11-28 02:17:45 +01:00
2014-07-21 22:46:54 +02:00
}
+
+ private void fireLoginEvents() throws Exception
+ {
+ // CraftBukkit start - fire PlayerPreLoginEvent
2014-11-28 02:17:45 +01:00
+ if (!this.a.networkManager.g()) {
2014-07-21 22:46:54 +02:00
+ return;
+ }
+
2014-11-28 02:17:45 +01:00
+ String playerName = LoginListener.b(this.a).getName();
2014-07-21 22:46:54 +02:00
+ java.net.InetAddress address = ((java.net.InetSocketAddress) a.networkManager.getSocketAddress()).getAddress();
2014-11-28 02:17:45 +01:00
+ java.util.UUID uniqueId = LoginListener.b(this.a).getId();
+ final org.bukkit.craftbukkit.CraftServer server = LoginListener.a(this.a).server;
2014-07-21 22:46:54 +02:00
+
+ AsyncPlayerPreLoginEvent asyncEvent = new AsyncPlayerPreLoginEvent(playerName, address, uniqueId);
+ server.getPluginManager().callEvent(asyncEvent);
+
+ if (PlayerPreLoginEvent.getHandlerList().getRegisteredListeners().length != 0) {
+ final PlayerPreLoginEvent event = new PlayerPreLoginEvent(playerName, address, uniqueId);
+ 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();
+ }};
+
2014-11-28 02:17:45 +01:00
+ LoginListener.a(this.a).processQueue.add(waitable);
2014-07-21 22:46:54 +02:00
+ 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
+
2014-11-28 02:17:45 +01:00
+ LoginListener.e().info("UUID of player " + LoginListener.b(this.a).getName() + " is " + LoginListener.b(this.a).getId());
2014-07-21 22:46:54 +02:00
+ LoginListener.a(this.a, EnumProtocolState.READY_TO_ACCEPT);
+ }
}
--
2014-11-28 02:17:45 +01:00
2.1.0
2014-07-21 22:46:54 +02:00