mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-09 20:30:28 +01:00
7b0c576798
Allows us much greater control over the Spigot portion of the code and makes us more "proper" Credit to @Dmck2b for originally passing the idea along a while back
160 lines
7.4 KiB
Diff
160 lines
7.4 KiB
Diff
From f48253e81390ceb92c9fa7adeeea091e3bc66a02 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 8f982f1..0755d36 100644
|
|
--- a/src/main/java/net/minecraft/server/LoginListener.java
|
|
+++ b/src/main/java/net/minecraft/server/LoginListener.java
|
|
@@ -59,10 +59,23 @@ public class LoginListener implements PacketLoginInListener {
|
|
}
|
|
}
|
|
|
|
+ // 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
|
|
+
|
|
public void c() {
|
|
+ // Spigot start - Moved to initUUID
|
|
+ /*
|
|
if (!this.i.isComplete()) {
|
|
this.i = this.a(this.i);
|
|
}
|
|
+ */
|
|
+ // Spigot end
|
|
|
|
// CraftBukkit start - fire PlayerLoginEvent
|
|
EntityPlayer s = this.server.getPlayerList().attemptLogin(this, this.i, this.hostname);
|
|
@@ -97,7 +110,7 @@ public class LoginListener implements PacketLoginInListener {
|
|
this.g = EnumProtocolState.KEY;
|
|
this.networkManager.handle(new PacketLoginOutEncryptionBegin(this.j, this.server.K().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 6b91be7..1b2620c 100644
|
|
--- a/src/main/java/net/minecraft/server/ThreadPlayerLookupUUID.java
|
|
+++ b/src/main/java/net/minecraft/server/ThreadPlayerLookupUUID.java
|
|
@@ -25,50 +25,19 @@ class ThreadPlayerLookupUUID extends Thread {
|
|
GameProfile gameprofile = LoginListener.a(this.a);
|
|
|
|
try {
|
|
+ // Spigot Start
|
|
+ if ( !LoginListener.c( this.a ).getOnlineMode() )
|
|
+ {
|
|
+ a.initUUID();
|
|
+ fireLoginEvents();
|
|
+ return;
|
|
+ }
|
|
+ // Spigot End
|
|
String s = (new BigInteger(MinecraftEncryption.a(LoginListener.b(this.a), LoginListener.c(this.a).K().getPublic(), LoginListener.d(this.a)))).toString(16);
|
|
|
|
LoginListener.a(this.a, LoginListener.c(this.a).av().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s));
|
|
if (LoginListener.a(this.a) != null) {
|
|
- // CraftBukkit start - fire PlayerPreLoginEvent
|
|
- if (!this.a.networkManager.isConnected()) {
|
|
- return;
|
|
- }
|
|
-
|
|
- String playerName = LoginListener.a(this.a).getName();
|
|
- java.net.InetAddress address = ((java.net.InetSocketAddress) a.networkManager.getSocketAddress()).getAddress();
|
|
- java.util.UUID uniqueId = LoginListener.a(this.a).getId();
|
|
- final org.bukkit.craftbukkit.CraftServer server = LoginListener.c(this.a).server;
|
|
-
|
|
- 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();
|
|
- }};
|
|
-
|
|
- LoginListener.c(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
|
|
-
|
|
- LoginListener.e().info("UUID of player " + LoginListener.a(this.a).getName() + " is " + LoginListener.a(this.a).getId());
|
|
- LoginListener.a(this.a, EnumProtocolState.READY_TO_ACCEPT);
|
|
+ fireLoginEvents(); // Spigot
|
|
} else if (LoginListener.c(this.a).N()) {
|
|
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 {
|
|
// CraftBukkit end
|
|
}
|
|
}
|
|
+
|
|
+ private void fireLoginEvents() throws Exception
|
|
+ {
|
|
+ // CraftBukkit start - fire PlayerPreLoginEvent
|
|
+ if (!this.a.networkManager.isConnected()) {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ String playerName = LoginListener.a(this.a).getName();
|
|
+ java.net.InetAddress address = ((java.net.InetSocketAddress) a.networkManager.getSocketAddress()).getAddress();
|
|
+ java.util.UUID uniqueId = LoginListener.a(this.a).getId();
|
|
+ final org.bukkit.craftbukkit.CraftServer server = LoginListener.c(this.a).server;
|
|
+
|
|
+ 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();
|
|
+ }};
|
|
+
|
|
+ LoginListener.c(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
|
|
+
|
|
+ LoginListener.e().info("UUID of player " + LoginListener.a(this.a).getName() + " is " + LoginListener.a(this.a).getId());
|
|
+ LoginListener.a(this.a, EnumProtocolState.READY_TO_ACCEPT);
|
|
+ }
|
|
}
|
|
--
|
|
1.9.1
|
|
|