Skip to content

Commit

Permalink
Fix terminal color on Windows (#176)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Dreeam-qwq authored Dec 1, 2024
1 parent 714cb8a commit 0510b51
Show file tree
Hide file tree
Showing 81 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
Date: Thu, 2 May 2024 20:21:29 -0400
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
index 316654051b80ac0fd62cf3b7a0e1b91010ec24b7..9a9bd633c6ed1b2231d36ef7a285a1f1463ccee4 100644
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
Date: Sat, 4 May 2024 02:46:17 -0400
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
Solution refers to https://inside.java/2023/07/31/quality-heads-up

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
Date: Thu, 27 Jun 2024 01:13:07 +0800
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

diff --git a/src/main/java/org/dreeam/leaf/LeafBootstrap.java b/src/main/java/org/dreeam/leaf/LeafBootstrap.java
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Original project: https://github.com/PaperMC/Paper
Paper pull request: https://github.com/PaperMC/Paper/pull/11631

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

Expand All @@ -27,3 +28,15 @@ index 068ec805a51764fbe22b91578797e553a7bca1f8..572af93c43a66e6ae17b4aee219a87c5
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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ index c4965b7582edfdf97cac82c1472f8fcc1a880a6b..d55560a12be8846db7c0969f5e72f3d7
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
index 2f5122a61af183d6a4c20a175122c228b6e9fc48..9055727c16659ae43eb5424f0aa61e419f53483e 100644
index 0052062cdfcb7672bec177c3d3788f7b1a56d3e5..fbfcb237996674c26d2eff0075c1aa8a447ad2a4 100644
--- a/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;
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 0510b51

Please sign in to comment.