9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00
Files
Leaf/leaf-archived-patches/removed/1.21.3/server/0126-Paper-Fix-move-to-jline-terminal-ffm-on-java-22-and-.patch
2025-06-29 23:39:55 +08:00

45 lines
2.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MiniDigger | Martin <admin@minidigger.dev>
Date: Sun, 17 Nov 2024 20:31:50 +0100
Subject: [PATCH] Paper: Fix: move to jline-terminal-ffm on java 22+ and fall
back to jni on 21
Removed since Leaf 1.21.3, Paper 1.21.3 included it
Original license: GPLv3
Original project: https://github.com/PaperMC/Paper
Paper pull request: https://github.com/PaperMC/Paper/pull/11631
Ported from Paper 1.21.3
And added terminal color fix on Windows
We assume that the Windows supports truecolor, even if the environment variables TERM and COLORTERM are null
ffm requires 1) native access allowed (the jdk cracks down on undocumented native access in 22) and 2) reverting the default console back to java.base, so the internal jline doesnt take over
diff --git a/build.gradle.kts b/build.gradle.kts
index 068ec805a51764fbe22b91578797e553a7bca1f8..572af93c43a66e6ae17b4aee219a87c5168e3dfa 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -31,7 +31,8 @@ dependencies {
// Leaf end - Libraries
// Paper start
- implementation("org.jline:jline-terminal-jansi:3.27.1") // Leaf - Bump Dependencies
+ implementation("org.jline:jline-terminal-ffm:3.27.1") // Paper - use ffm on java 22+
+ implementation("org.jline:jline-terminal-jni:3.27.1") // Paper - fall back to jni on java 21
implementation("net.minecrell:terminalconsoleappender:1.3.0")
implementation("net.kyori:adventure-text-serializer-ansi:4.17.0") // Keep in sync with adventureVersion from Paper-API build file
/*
diff --git a/src/main/java/org/dreeam/leaf/LeafBootstrap.java b/src/main/java/org/dreeam/leaf/LeafBootstrap.java
index 316654051b80ac0fd62cf3b7a0e1b91010ec24b7..ff0ef887b892caa1451b5781d95f5505cfa2e413 100644
--- a/src/main/java/org/dreeam/leaf/LeafBootstrap.java
+++ b/src/main/java/org/dreeam/leaf/LeafBootstrap.java
@@ -12,5 +12,7 @@ public class LeafBootstrap {
}
private static void runPreBootTasks() {
+ if (org.jline.utils.OSUtils.IS_WINDOWS) System.setProperty("net.kyori.ansi.colorLevel", "truecolor"); // Leaf - Fix terminal color on Windows by assuming the Windows always supports true color
+ if (org.galemc.gale.virtualthread.VirtualThreadService.getJavaMajorVersion() == 22) System.setProperty("jdk.console", "java.base"); // Leaf - Fix terminal input freeze on Java 22, higher Java version looks like fine
}
}