2019-05-05 19:19:34 +02:00
|
|
|
From 958395a3ff4635072301a6fc0fe288e5470421f9 Mon Sep 17 00:00:00 2001
|
2019-04-01 07:18:39 +02:00
|
|
|
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
|
|
|
|
Date: Sun, 31 Mar 2019 22:02:24 -0700
|
|
|
|
Subject: [PATCH] Allow login events to fire only after the server plugins are
|
|
|
|
enabled
|
|
|
|
|
|
|
|
Event threads will simply block until they're ready to accept.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/LoginListener.java b/src/main/java/net/minecraft/server/LoginListener.java
|
2019-05-05 19:19:34 +02:00
|
|
|
index 9e4bc24058..028c23dbe6 100644
|
2019-04-01 07:18:39 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/LoginListener.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/LoginListener.java
|
2019-05-05 19:19:34 +02:00
|
|
|
@@ -285,6 +285,36 @@ public class LoginListener implements PacketLoginInListener {
|
2019-04-01 07:18:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start - Delay async prelogin until plugins are ready
|
|
|
|
+ private static volatile Object blockingLogins = new Object();
|
|
|
|
+
|
|
|
|
+ public static void checkStartupAndBlock() {
|
|
|
|
+ final Object lock = LoginListener.blockingLogins;
|
|
|
|
+ if (lock != null) {
|
|
|
|
+ synchronized (lock) {
|
|
|
|
+ for (;;) {
|
|
|
|
+ if (LoginListener.blockingLogins == null) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ lock.wait();
|
|
|
|
+ } catch (final InterruptedException ignore) {// handled by the if statement above
|
|
|
|
+ Thread.currentThread().interrupt();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static void allowLogins() {
|
|
|
|
+ final Object lock = LoginListener.blockingLogins;
|
|
|
|
+ synchronized (lock) {
|
|
|
|
+ LoginListener.blockingLogins = null;
|
|
|
|
+ lock.notifyAll();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
// Spigot start
|
|
|
|
public class LoginHandler {
|
|
|
|
|
2019-05-05 19:19:34 +02:00
|
|
|
@@ -295,6 +325,7 @@ public class LoginListener implements PacketLoginInListener {
|
2019-04-01 07:18:39 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Paper end
|
|
|
|
+ LoginListener.checkStartupAndBlock(); // Paper - Delay async login events until plugins are ready
|
|
|
|
String playerName = i.getName();
|
|
|
|
java.net.InetAddress address = ((java.net.InetSocketAddress) networkManager.getSocketAddress()).getAddress();
|
|
|
|
java.util.UUID uniqueId = i.getId();
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
2019-05-05 19:19:34 +02:00
|
|
|
index b790472347..c28b0738dd 100644
|
2019-04-01 07:18:39 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
2019-05-05 19:19:34 +02:00
|
|
|
@@ -461,6 +461,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
|
|
|
// Paper end
|
|
|
|
|
2019-04-01 07:18:39 +02:00
|
|
|
this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.POSTWORLD);
|
|
|
|
+ LoginListener.allowLogins(); // Paper - Allow logins once postworld
|
|
|
|
this.server.getPluginManager().callEvent(new ServerLoadEvent(ServerLoadEvent.LoadType.STARTUP));
|
|
|
|
// CraftBukkit end
|
2019-05-05 19:19:34 +02:00
|
|
|
|
2019-04-01 07:18:39 +02:00
|
|
|
--
|
|
|
|
2.21.0
|
|
|
|
|