From 1895a51bc8ae18591ad19bde12d5a6dbfc597d87 Mon Sep 17 00:00:00 2001 From: md_5 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 efba029..6f35aa0 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.J().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 f48ce53..2723fb8 100644 --- a/src/main/java/net/minecraft/server/ThreadPlayerLookupUUID.java +++ b/src/main/java/net/minecraft/server/ThreadPlayerLookupUUID.java @@ -22,47 +22,20 @@ 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).J().getPublic(), LoginListener.c(this.a)))).toString(16); - LoginListener.a(this.a, LoginListener.b(this.a).at().hasJoinedServer(new GameProfile((String) null, LoginListener.d(this.a).getName()), s)); if (LoginListener.d(this.a) != null) { - // CraftBukkit start - fire PlayerPreLoginEvent - if (!this.a.networkManager.isConnected()) { - 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 waitable = new Waitable() { - @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 +52,44 @@ class ThreadPlayerLookupUUID extends Thread { // CraftBukkit end } } + + private void fireLoginEvents() throws Exception + { + // CraftBukkit start - fire PlayerPreLoginEvent + if (!this.a.networkManager.isConnected()) { + 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 waitable = new Waitable() { + @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.5.2.msysgit.0