diff --git a/paper-server/patches/sources/net/minecraft/Util.java.patch b/paper-server/patches/sources/net/minecraft/Util.java.patch index 739ac916a..52e4eae25 100644 --- a/paper-server/patches/sources/net/minecraft/Util.java.patch +++ b/paper-server/patches/sources/net/minecraft/Util.java.patch @@ -1,6 +1,29 @@ --- a/net/minecraft/Util.java +++ b/net/minecraft/Util.java -@@ -136,7 +136,7 @@ +@@ -95,6 +95,22 @@ + private static final TracingExecutor BACKGROUND_EXECUTOR = makeExecutor("Main"); + private static final TracingExecutor IO_POOL = makeIoExecutor("IO-Worker-", false); + private static final TracingExecutor DOWNLOAD_POOL = makeIoExecutor("Download-", true); ++ // Paper start - don't submit BLOCKING PROFILE LOOKUPS to the world gen thread ++ public static final ExecutorService PROFILE_EXECUTOR = Executors.newFixedThreadPool(2, new java.util.concurrent.ThreadFactory() { ++ ++ private final AtomicInteger count = new AtomicInteger(); ++ ++ @Override ++ public Thread newThread(Runnable run) { ++ Thread ret = new Thread(run); ++ ret.setName("Profile Lookup Executor #" + this.count.getAndIncrement()); ++ ret.setUncaughtExceptionHandler((Thread thread, Throwable throwable) -> { ++ LOGGER.error("Uncaught exception in thread " + thread.getName(), throwable); ++ }); ++ return ret; ++ } ++ }); ++ // Paper end - don't submit BLOCKING PROFILE LOOKUPS to the world gen thread + private static final DateTimeFormatter FILENAME_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss", Locale.ROOT); + public static final int LINEAR_LOOKUP_THRESHOLD = 8; + private static final Set ALLOWED_UNTRUSTED_LINK_PROTOCOLS = Set.of("http", "https"); +@@ -136,7 +152,7 @@ } public static long getNanos() { @@ -9,7 +32,7 @@ } public static long getEpochMillis() { -@@ -537,7 +537,7 @@ +@@ -537,7 +553,7 @@ public static , V> EnumMap makeEnumMap(Class enumClass, Function mapper) { EnumMap enumMap = new EnumMap<>(enumClass); diff --git a/paper-server/patches/sources/net/minecraft/server/players/GameProfileCache.java.patch b/paper-server/patches/sources/net/minecraft/server/players/GameProfileCache.java.patch index 06c15a0ab..a71d66163 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/GameProfileCache.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/GameProfileCache.java.patch @@ -51,6 +51,15 @@ } return optional; +@@ -167,7 +169,7 @@ + } else { + CompletableFuture> completablefuture1 = CompletableFuture.supplyAsync(() -> { + return this.get(username); +- }, Util.backgroundExecutor().forName("getProfile")).whenCompleteAsync((optional, throwable) -> { ++ }, Util.PROFILE_EXECUTOR).whenCompleteAsync((optional, throwable) -> { // Paper - don't submit BLOCKING PROFILE LOOKUPS to the world gen thread + this.requests.remove(username); + }, this.executor); + @@ -208,7 +210,7 @@ label54: diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SkullBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SkullBlockEntity.java.patch new file mode 100644 index 000000000..348568625 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SkullBlockEntity.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/block/entity/SkullBlockEntity.java ++++ b/net/minecraft/world/level/block/entity/SkullBlockEntity.java +@@ -105,7 +105,7 @@ + ProfileResult profileResult = apiServices.sessionService().fetchProfile(uuid, true); + return Optional.ofNullable(profileResult).map(ProfileResult::profile); + } +- }, Util.backgroundExecutor().forName("fetchProfile")); ++ }, Util.PROFILE_EXECUTOR); // Paper - don't submit BLOCKING PROFILE LOOKUPS to the world gen thread + } + + public static void clear() { diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java b/paper-server/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java index 26a7c2d37..210fdad5f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java @@ -161,7 +161,7 @@ public final class CraftPlayerProfile implements PlayerProfile { @Override public CompletableFuture update() { - return CompletableFuture.supplyAsync(this::getUpdatedProfile, Util.backgroundExecutor()); + return CompletableFuture.supplyAsync(this::getUpdatedProfile, Util.PROFILE_EXECUTOR); // Paper - don't submit BLOCKING PROFILE LOOKUPS to the world gen thread } private CraftPlayerProfile getUpdatedProfile() {