Paper/Spigot-Server-Patches/0378-Allow-login-events-to-fire-only-after-the-server-plu.patch
Shane Freeder 73983e4c16
Updated Upstream (Bukkit/CraftBukkit/Spigot)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
3dc4cdcd Update to Minecraft 1.14.3-pre4
88b25a8c SPIGOT-5098: Add a method to allow colored sign changes
6d913552 Update to Minecraft 1.14.3-pre4

CraftBukkit Changes:
f1f33559 Update to Minecraft 1.14.3
8a3d3f49 SPIGOT-5098: Add a method to allow colored sign changes
533290e2 SPIGOT-5100: Console warning from pig zombie targeting
6dde4b9f SPIGOT-5094: Allow opening merchant for wandering traders and hide the xp bar for custom merchants
9af90077 SPIGOT-5097: Bukkit.clearRecipes() no longer working
38fa220f Fix setting game rules via the API
fe3930ce Update to Minecraft 1.14.3-pre4
da071ec5 Remove outdated build delay.

Spigot Changes:
4d2f30f1 Update to Minecraft 1.14.3
f16400e3 Update to Minecraft 1.14.3-pre4
2019-06-25 03:46:54 +01:00

73 lines
3.0 KiB
Diff

From ea6d715ab826c8709c7918f7975b7a8c1bcf92a4 Mon Sep 17 00:00:00 2001
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
index 9e4bc24058..028c23dbe6 100644
--- a/src/main/java/net/minecraft/server/LoginListener.java
+++ b/src/main/java/net/minecraft/server/LoginListener.java
@@ -285,6 +285,36 @@ public class LoginListener implements PacketLoginInListener {
}
}
+ // 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 {
@@ -295,6 +325,7 @@ public class LoginListener implements PacketLoginInListener {
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
index c20d9aab38..56951b44f9 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -461,6 +461,7 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
// Paper end
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
--
2.22.0