9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-23 00:49:31 +00:00

Fix terminal color on Windows (#176)

* Fix terminal color on Windows

Windows doesn't have environment variables TERM and COLORTERM by default, but we assuming that it supports the `truecolor` for terminal.

* Add back revert to original java console on Java 22
This commit is contained in:
Dreeam
2024-11-30 20:01:54 -05:00
committed by GitHub
parent 714cb8a9cf
commit 0510b51ed3
81 changed files with 23 additions and 2 deletions

View File

@@ -3,6 +3,8 @@ From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
Date: Thu, 2 May 2024 20:21:29 -0400 Date: Thu, 2 May 2024 20:21:29 -0400
Subject: [PATCH] Ignore terminal provider warning Subject: [PATCH] Ignore terminal provider warning
Removed since Leaf 1.21.1, since ported jline update from Paper 1.21.3
don't need deprected jansi anymore
diff --git a/src/main/java/org/dreeam/leaf/LeafBootstrap.java b/src/main/java/org/dreeam/leaf/LeafBootstrap.java diff --git a/src/main/java/org/dreeam/leaf/LeafBootstrap.java b/src/main/java/org/dreeam/leaf/LeafBootstrap.java
index 316654051b80ac0fd62cf3b7a0e1b91010ec24b7..9a9bd633c6ed1b2231d36ef7a285a1f1463ccee4 100644 index 316654051b80ac0fd62cf3b7a0e1b91010ec24b7..9a9bd633c6ed1b2231d36ef7a285a1f1463ccee4 100644

View File

@@ -3,6 +3,9 @@ From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
Date: Sat, 4 May 2024 02:46:17 -0400 Date: Sat, 4 May 2024 02:46:17 -0400
Subject: [PATCH] Fix console freeze above JAVA 22 Subject: [PATCH] Fix console freeze above JAVA 22
Removed since Leaf 1.21.1, since ported jline update from Paper 1.21.3
Console input command seems work soomthly on Java 22+
Revert to old console provider, Fix https://github.com/PaperMC/Paper/issues/10405 Revert to old console provider, Fix https://github.com/PaperMC/Paper/issues/10405
Solution refers to https://inside.java/2023/07/31/quality-heads-up Solution refers to https://inside.java/2023/07/31/quality-heads-up

View File

@@ -3,6 +3,9 @@ From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
Date: Thu, 27 Jun 2024 01:13:07 +0800 Date: Thu, 27 Jun 2024 01:13:07 +0800
Subject: [PATCH] Fix console output display on Pterodactyl panel Subject: [PATCH] Fix console output display on Pterodactyl panel
Removed since Leaf 1.21.1, since ported jline update from Paper 1.21.3
No need to add flags `-Dterminal.jline=false` and `-Dterminal.ansi=true`
Fixed console display issue when the terminal used xterm, should work on Pterodactyl, MCSManager and kind of panel software Fixed console display issue when the terminal used xterm, should work on Pterodactyl, MCSManager and kind of panel software
diff --git a/src/main/java/org/dreeam/leaf/LeafBootstrap.java b/src/main/java/org/dreeam/leaf/LeafBootstrap.java diff --git a/src/main/java/org/dreeam/leaf/LeafBootstrap.java b/src/main/java/org/dreeam/leaf/LeafBootstrap.java

View File

@@ -9,7 +9,8 @@ Original project: https://github.com/PaperMC/Paper
Paper pull request: https://github.com/PaperMC/Paper/pull/11631 Paper pull request: https://github.com/PaperMC/Paper/pull/11631
Ported from Paper 1.21.3 Ported from Paper 1.21.3
Also see Leaf's Fix-console-freeze-above-JAVA-22.patch 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 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
@@ -27,3 +28,15 @@ index 068ec805a51764fbe22b91578797e553a7bca1f8..572af93c43a66e6ae17b4aee219a87c5
implementation("net.minecrell:terminalconsoleappender:1.3.0") 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 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
}
}

View File

@@ -69,7 +69,7 @@ index c4965b7582edfdf97cac82c1472f8fcc1a880a6b..d55560a12be8846db7c0969f5e72f3d7
public void playerTouch(Player player) {} public void playerTouch(Player player) {}
diff --git a/src/main/java/org/dreeam/leaf/LeafBootstrap.java b/src/main/java/org/dreeam/leaf/LeafBootstrap.java diff --git a/src/main/java/org/dreeam/leaf/LeafBootstrap.java b/src/main/java/org/dreeam/leaf/LeafBootstrap.java
index 2f5122a61af183d6a4c20a175122c228b6e9fc48..9055727c16659ae43eb5424f0aa61e419f53483e 100644 index 0052062cdfcb7672bec177c3d3788f7b1a56d3e5..fbfcb237996674c26d2eff0075c1aa8a447ad2a4 100644
--- a/src/main/java/org/dreeam/leaf/LeafBootstrap.java --- a/src/main/java/org/dreeam/leaf/LeafBootstrap.java
+++ b/src/main/java/org/dreeam/leaf/LeafBootstrap.java +++ b/src/main/java/org/dreeam/leaf/LeafBootstrap.java
@@ -4,6 +4,7 @@ import io.papermc.paper.PaperBootstrap; @@ -4,6 +4,7 @@ import io.papermc.paper.PaperBootstrap;