mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-28 13:36:16 +01:00
8c5b837e05
Firstly, the old methods all routed to the CompletableFuture method. However, the CF method could not guarantee that if the caller was off-main that the future would be "completed" on-main. Since the callback methods used the CF one, this meant that the callback methods did not guarantee that the callbacks were to be called on the main thread. Now, all methods route to getChunkAtAsync(x, z, gen, urgent, cb) so that the methods with the callback are guaranteed to invoke the callback on the main thread. The CF behavior remains unchanged; it may still appear to complete on main if invoked off-main. Secondly, remove the scheduleOnMain invocation in the async chunk completion. This unnecessarily delays the callback by 1 tick. Thirdly, add getChunksAtAsync(minX, minZ, maxX, maxZ, ...) which will load chunks within an area. This method is provided as a helper as keeping all chunks loaded within an area can be complicated to implement for plugins (due to the lacking ticket API), and is already implemented internally anyways. Fourthly, remove the ticket addition that occured with getChunkAt and getChunkAtAsync. The ticket addition may delay the unloading of the chunk unnecessarily. It also fixes a very rare timing bug where the future/callback would be completed after the chunk unloads.
52 lines
2.5 KiB
Diff
52 lines
2.5 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Noah van der Aa <ndvdaa@gmail.com>
|
|
Date: Sat, 22 Oct 2022 14:47:45 +0200
|
|
Subject: [PATCH] Detect headless JREs
|
|
|
|
Crashes caused by the missing AWT dependency come up in the support channels fairly often.
|
|
This patch detects the missing dependency and stops the server with a clear error message,
|
|
containing a link to instructions on how to install a non-headless JRE.
|
|
|
|
diff --git a/src/main/java/io/papermc/paper/util/ServerEnvironment.java b/src/main/java/io/papermc/paper/util/ServerEnvironment.java
|
|
index 68098dfe716e93aafcca4d8d5b5a81d8648b3654..2b7070e0cefa7cf0777df159693750fea14e800b 100644
|
|
--- a/src/main/java/io/papermc/paper/util/ServerEnvironment.java
|
|
+++ b/src/main/java/io/papermc/paper/util/ServerEnvironment.java
|
|
@@ -20,4 +20,14 @@ public class ServerEnvironment {
|
|
public static boolean userIsRootOrAdmin() {
|
|
return RUNNING_AS_ROOT_OR_ADMIN;
|
|
}
|
|
+
|
|
+ public static String awtDependencyCheck() {
|
|
+ try {
|
|
+ new java.awt.Color(0);
|
|
+ } catch (UnsatisfiedLinkError e) {
|
|
+ return e.getClass().getName() + ": " + e.getMessage();
|
|
+ }
|
|
+
|
|
+ return null;
|
|
+ }
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/Main.java b/src/main/java/net/minecraft/server/Main.java
|
|
index cf071610ed662c4a309cc26ee73a74fa490d846f..47cd7c66ac37efebf2f63c49d78dd8fe44a70ef8 100644
|
|
--- a/src/main/java/net/minecraft/server/Main.java
|
|
+++ b/src/main/java/net/minecraft/server/Main.java
|
|
@@ -167,6 +167,18 @@ public class Main {
|
|
return;
|
|
}
|
|
|
|
+ // Paper start - Detect headless JRE
|
|
+ String awtException = io.papermc.paper.util.ServerEnvironment.awtDependencyCheck();
|
|
+ if (awtException != null) {
|
|
+ Main.LOGGER.error("You are using a headless JRE distribution.");
|
|
+ Main.LOGGER.error("This distribution is missing certain graphic libraries that the Minecraft server needs to function.");
|
|
+ Main.LOGGER.error("For instructions on how to install the non-headless JRE, see https://docs.papermc.io/misc/java-install");
|
|
+ Main.LOGGER.error("");
|
|
+ Main.LOGGER.error(awtException);
|
|
+ return;
|
|
+ }
|
|
+ // Paper end - Detect headless JRE
|
|
+
|
|
org.spigotmc.SpigotConfig.disabledAdvancements = spigotConfiguration.getStringList("advancements.disabled"); // Paper - fix SPIGOT-5885, must be set early in init
|
|
// Paper start - fix SPIGOT-5824
|
|
File file;
|