summaryrefslogtreecommitdiffstats
path: root/nms-patches/ThreadPlayerLookupUUID.patch
diff options
context:
space:
mode:
authorThinkofdeath <thinkofdeath@spigotmc.org>2014-11-26 08:32:16 +1100
committermd_5 <git@md-5.net>2014-11-28 17:16:30 +1100
commit24557bc2b37deb6a0edf497d547471832457b1dd (patch)
treec560572889a3b0b34964a0cddb35dc87fda3c914 /nms-patches/ThreadPlayerLookupUUID.patch
parenta4805dbd77da057cc1ea0bf344379bc6e53ca1f6 (diff)
downloadcraftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar
craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar.gz
craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar.lz
craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar.xz
craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.zip
Update to Minecraft 1.8
For more information please see http://www.spigotmc.org/
Diffstat (limited to 'nms-patches/ThreadPlayerLookupUUID.patch')
-rw-r--r--nms-patches/ThreadPlayerLookupUUID.patch72
1 files changed, 72 insertions, 0 deletions
diff --git a/nms-patches/ThreadPlayerLookupUUID.patch b/nms-patches/ThreadPlayerLookupUUID.patch
new file mode 100644
index 00000000..d0732690
--- /dev/null
+++ b/nms-patches/ThreadPlayerLookupUUID.patch
@@ -0,0 +1,72 @@
+--- ../work/decompile-bb26c12b/net/minecraft/server/ThreadPlayerLookupUUID.java 2014-11-27 08:59:46.901420966 +1100
++++ src/main/java/net/minecraft/server/ThreadPlayerLookupUUID.java 2014-11-27 08:42:10.164850887 +1100
+@@ -5,6 +5,12 @@
+ import java.math.BigInteger;
+ import java.util.UUID;
+
++// CraftBukkit start
++import org.bukkit.craftbukkit.util.Waitable;
++import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
++import org.bukkit.event.player.PlayerPreLoginEvent;
++// CraftBukkit end
++
+ class ThreadPlayerLookupUUID extends Thread {
+
+ final LoginListener a;
+@@ -22,6 +28,44 @@
+
+ LoginListener.a(this.a, LoginListener.a(this.a).aB().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s));
+ if (LoginListener.b(this.a) != null) {
++ // CraftBukkit start - fire PlayerPreLoginEvent
++ if (!this.a.networkManager.g()) {
++ return;
++ }
++
++ String playerName = LoginListener.a(this.a).getName();
++ java.net.InetAddress address = ((java.net.InetSocketAddress) a.networkManager.getSocketAddress()).getAddress();
++ java.util.UUID uniqueId = LoginListener.b(this.a).getId();
++ final org.bukkit.craftbukkit.CraftServer server = LoginListener.a(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.a(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.b(this.a).getName() + " is " + LoginListener.b(this.a).getId());
+ LoginListener.a(this.a, EnumProtocolState.READY_TO_ACCEPT);
+ } else if (LoginListener.a(this.a).S()) {
+@@ -41,6 +85,11 @@
+ this.a.disconnect("Authentication servers are down. Please try again later, sorry!");
+ LoginListener.e().error("Couldn\'t verify username because servers are unavailable");
+ }
++ // CraftBukkit start - catch all exceptions
++ } catch (Exception exception) {
++ this.a.disconnect("Failed to verify username!");
++ LoginListener.a(this.a).server.getLogger().log(java.util.logging.Level.WARNING, "Exception verifying " + LoginListener.a(this.a).getName(), exception);
++ // CraftBukkit end
+ }
+
+ }