Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOTD colors displaying incorrectly on GraalVM #2487

Closed
cn-ml opened this issue Nov 12, 2023 · 14 comments · Fixed by #3189
Closed

MOTD colors displaying incorrectly on GraalVM #2487

cn-ml opened this issue Nov 12, 2023 · 14 comments · Fixed by #3189

Comments

@cn-ml
Copy link

cn-ml commented Nov 12, 2023

Describe the problem

The MOTD of my server displays incorrectly: Instead of the color codes entered as environment variables the motd contains two unknown characters instead of the color formatting sign:

image

I tried all of the below versions:

"welcome to &athis server&r!&r\nwe are playing &bVanilla Minecraft &d1.20.2"
"welcome to §athis server§r!§r\nwe are playing §bVanilla Minecraft §d1.20.2"
"welcome to \u00a7athis server\u00a7r!\u00a7r\nwe are playing \u00a7bVanilla Minecraft \u00a7d1.20.2"
# even the simplest with and without quotes
A §l§cMinecraft§r §nserver

Container definition

services:
  server:
    restart: always
    image: itzg/minecraft-server:java17-graalvm
    depends_on:
      - db
    env_file: stack.env
    environment:
      UID: 1001
      GID: 1001

      TYPE: PURPUR
      PURPUR_BUILD: LATEST
      REMOVE_OLD_MODS: true

      MEMORY: 2G
      USE_AIKAR_FLAGS: true

      MOTD: A §l§cMinecraft§r §nserver
      #MOTD: "A §l§cMinecraft§r §nserver"
      #MOTD: "welcome to &athis server&r!&r\nwe are playing &bVanilla Minecraft &d1.20.2"
      #MOTD: "welcome to §athis server§r!§r\nwe are playing §bVanilla Minecraft §d1.20.2"
      #MOTD: "welcome to \u00a7athis server\u00a7r!\u00a7r\nwe are playing \u00a7bVanilla Minecraft \u00a7d1.20.2"
      DIFFICULTY: normal
      SPAWN_PROTECTION: 0
      MODE: survival
      ENABLE_QUERY: true
      QUERY_PORT: 25565
      MAX_PLAYERS: 20
      OPS: |-
        player1
      EXISTING_OPS_FILE: SYNCHRONIZE
      WHITELIST: |-
        player1
        player2
      EXISTING_WHITELIST_FILE: SYNCHRONIZE
      ENFORCE_WHITELIST: true
      ICON: <my icon>
      OVERRIDE_ICON: true
      TZ: <my timezone>
      ENABLE_ROLLING_LOGS: true
      USE_SIMD_FLAGS: true

      EULA: true
    stop_grace_period: 2m
    ports:
      - 25562:25565/tcp # Server Port
      - 25562:25565/udp # Query Port
    volumes:
      - /data/minecraft/data:/data
      - /data/minecraft/plugins:/plugins:ro
# rest omitted

Container logs

[init] Changing uid of minecraft to 1001
[init] Changing gid of minecraft to 1001
[init] Running as uid=1001 gid=1001 with /data as 'drwxr-xr-x 13 1001 1001 4096 Nov 13 00:28 /data'
[init] Resolving type given PURPUR
[mc-image-helper] 00:31:05.825 INFO  : Resolved Purpur version 1.20.2 build 2090
[mc-image-helper] 00:31:05.858 INFO  : The file /data/purpur-1.20.2-2090.jar is already up to date
[init] Removing old mods including:*.jar,*-version.json excluding:
[init] Copying any plugins from /plugins to /data/plugins
[mc-image-helper] 00:31:09.077 INFO  : Copying /plugins/BlueMap-3.17-paper.jar -> /data/plugins/BlueMap-3.17-paper.jar
[mc-image-helper] 00:31:09.085 INFO  : Copying /plugins/Vault.1.7.3.jar -> /data/plugins/Vault.1.7.3.jar
[mc-image-helper] 00:31:09.086 INFO  : Copying /plugins/CoreProtect-22.2.jar -> /data/plugins/CoreProtect-22.2.jar
[mc-image-helper] 00:31:09.087 INFO  : Copying /plugins/EssentialsXChat-2.20.1.jar -> /data/plugins/EssentialsXChat-2.20.1.jar
[mc-image-helper] 00:31:09.088 INFO  : Interpolating /plugins/EssentialsDiscord/config.yml -> /data/plugins/EssentialsDiscord/config.yml
[mc-image-helper] 00:31:09.094 INFO  : Copying /plugins/EssentialsXDiscordLink-2.20.1.jar -> /data/plugins/EssentialsXDiscordLink-2.20.1.jar
[mc-image-helper] 00:31:09.095 INFO  : Copying /plugins/InteractionVisualizer-1.18.7.0.jar -> /data/plugins/InteractionVisualizer-1.18.7.0.jar
[mc-image-helper] 00:31:09.099 INFO  : Interpolating /plugins/LuckPerms/config.yml -> /data/plugins/LuckPerms/config.yml
[mc-image-helper] 00:31:09.103 INFO  : Copying /plugins/EssentialsX-2.20.1.jar -> /data/plugins/EssentialsX-2.20.1.jar
[mc-image-helper] 00:31:09.106 INFO  : Copying /plugins/TAB v4.0.9.jar -> /data/plugins/TAB v4.0.9.jar
[mc-image-helper] 00:31:09.107 INFO  : Copying /plugins/EssentialsXDiscord-2.20.1.jar -> /data/plugins/EssentialsXDiscord-2.20.1.jar
[mc-image-helper] 00:31:09.112 INFO  : Copying /plugins/LuckPerms-Bukkit-5.4.106.jar -> /data/plugins/LuckPerms-Bukkit-5.4.106.jar
[init] Enabling whitelist functionality
[init] Setting mode
[mc-image-helper] 00:31:12.805 INFO  : Created/updated 2 properties in /data/server.properties
[init] Using server icon from <my icon>...
[init] log4j2.xml already created, skipping
[init] Using Aikar's flags
[init] Setting initial memory to 2G and max to 2G
[init] Starting the Minecraft server...
@itzg
Copy link
Owner

itzg commented Nov 13, 2023

It might be an issue with Purpur, but also be sure to re-pull the latest image since I have just made improvements to server properties unicode handling in the past couple of days. Speaking of which, you may need to set the newly added SERVER_PROPERTIES_ESCAPE_UNICODE to "true".

FWIW,

services:
  mc:
    image: itzg/minecraft-server
    environment:
      EULA: true
      MOTD: "A §l§cMinecraft§r §nserver"
    ports:
      - "25565:25565"
    volumes:
      - mc:/data
      
volumes: 
  mc: {}

correctly renders as
image

@itzg
Copy link
Owner

itzg commented Nov 13, 2023

...actually, changing that to

    environment:
      EULA: true
      MOTD: "A §l§cMinecraft§r §nserver"
      TYPE: PURPUR

still renders fine. If you're still having issues, add DUMP_SERVER_PROPERTIES: true and provide the server properties output during init.

@itzg
Copy link
Owner

itzg commented Nov 13, 2023

...and trying

    environment:
      EULA: true
      MOTD: "welcome to §athis server§r!§r\nwe are playing §bVanilla Minecraft §d1.20.2"
      TYPE: PURPUR
image

@cn-ml
Copy link
Author

cn-ml commented Nov 13, 2023

I just pulled the latest java17-graalvm tag from docker hub (3 hours old)

This is the output of the server startup when running with DUMP_SERVER_PROPERTIES: true with the compose environment variable MOTD: "Herzlich willkommen beim §aMinenhandwerk§r!§r\nWir spielen §bVanilla Minecraft §d1.20.2":

[init] Changing uid of minecraft to 1001
[init] Changing gid of minecraft to 1001
[init] Running as uid=1001 gid=1001 with /data as 'drwxr-xr-x 14 1001 1001 4096 Nov 13 02:22 /data'
[init] Resolving type given PURPUR
[mc-image-helper] 02:23:24.852 INFO  : Resolved Purpur version 1.20.2 build 2090
[mc-image-helper] 02:23:24.981 INFO  : The file /data/purpur-1.20.2-2090.jar is already up to date
[init] Removing old mods including:*.jar,*-version.json excluding:
[init] Copying any plugins from /plugins to /data/plugins
[mc-image-helper] 02:23:28.311 INFO  : Copying /plugins/BlueMap-3.17-paper.jar -> /data/plugins/BlueMap-3.17-paper.jar
[mc-image-helper] 02:23:28.320 INFO  : Copying /plugins/Vault.1.7.3.jar -> /data/plugins/Vault.1.7.3.jar
[mc-image-helper] 02:23:28.323 INFO  : Copying /plugins/CoreProtect-22.2.jar -> /data/plugins/CoreProtect-22.2.jar
[mc-image-helper] 02:23:28.324 INFO  : Interpolating /plugins/EssentialsDiscordLink/config.yml -> /data/plugins/EssentialsDiscordLink/config.yml
[mc-image-helper] 02:23:28.327 INFO  : Copying /plugins/EssentialsXChat-2.20.1.jar -> /data/plugins/EssentialsXChat-2.20.1.jar
[mc-image-helper] 02:23:28.328 INFO  : Interpolating /plugins/EssentialsDiscord/config.yml -> /data/plugins/EssentialsDiscord/config.yml
[mc-image-helper] 02:23:28.332 INFO  : Copying /plugins/EssentialsXDiscordLink-2.20.1.jar -> /data/plugins/EssentialsXDiscordLink-2.20.1.jar
[mc-image-helper] 02:23:28.334 INFO  : Interpolating /plugins/LuckPerms/config.yml -> /data/plugins/LuckPerms/config.yml
[mc-image-helper] 02:23:28.339 INFO  : Copying /plugins/EssentialsX-2.20.1.jar -> /data/plugins/EssentialsX-2.20.1.jar
[mc-image-helper] 02:23:28.342 INFO  : Copying /plugins/TAB v4.0.9.jar -> /data/plugins/TAB v4.0.9.jar
[mc-image-helper] 02:23:28.344 INFO  : Copying /plugins/EssentialsXDiscord-2.20.1.jar -> /data/plugins/EssentialsXDiscord-2.20.1.jar
[mc-image-helper] 02:23:28.350 INFO  : Copying /plugins/LuckPerms-Bukkit-5.4.106.jar -> /data/plugins/LuckPerms-Bukkit-5.4.106.jar
[init] Enabling whitelist functionality
[init] Setting mode
[init] DEBUG Dumping server.properties
#Minecraft server properties
#Mon Nov 13 02:22:41 CET 2023
enable-jmx-monitoring=false
level-seed=-6687876678944730503
rcon.port=25575
gamemode=survival
enable-command-block=false
enable-query=true
generator-settings={}
enforce-secure-profile=true
level-name=world
motd=Herzlich willkommen beim ��aMinenhandwerk��r\!��r\nWir spielen ��bVanilla Minecraft ��d1.20.2
query.port=25565
pvp=true
generate-structures=true
max-chained-neighbor-updates=1000000
difficulty=normal
network-compression-threshold=256
max-tick-time=60000
require-resource-pack=false
max-players=20
use-native-transport=true
online-mode=true
enable-status=true
allow-flight=false
initial-disabled-packs=
broadcast-rcon-to-ops=true
view-distance=10
server-ip=
resource-pack-prompt=
allow-nether=true
server-port=25565
enable-rcon=true
sync-chunk-writes=true
server-name=Unknown Server
op-permission-level=4
prevent-proxy-connections=false
hide-online-players=false
resource-pack=
entity-broadcast-range-percentage=100
simulation-distance=10
rcon.password=<private rcon password>
player-idle-timeout=0
debug=false
force-gamemode=false
rate-limit=0
hardcore=false
white-list=true
broadcast-console-to-ops=true
spawn-npcs=true
spawn-animals=true
log-ips=true
function-permission-level=2
initial-enabled-packs=vanilla
level-type=minecraft\:normal
text-filtering-config=
spawn-monsters=true
enforce-whitelist=true
spawn-protection=0
resource-pack-sha1=
max-world-size=29999984
[init] Using server icon from <my icon>...
[init] log4j2.xml already created, skipping
[init] Using Aikar's flags
[init] Setting initial memory to 2G and max to 2G
[init] Starting the Minecraft server...

@cn-ml
Copy link
Author

cn-ml commented Nov 13, 2023

I also just checked if the issue is during docker setup, but inspecting the docker container reveals that the environment variable is indeed set correctly (as shown above).

@itzg
Copy link
Owner

itzg commented Nov 13, 2023

Something seems to be unusual with GraalVM. I see what you are reporting with java17-graalvm but changing only the image to itzg/minecraft-server:java17 generates the properties file correctly:

motd=Herzlich willkommen beim §aMinenhandwerk§r\!§r\nWir spielen §bVanilla Minecraft §d1.20.2

@cn-ml
Copy link
Author

cn-ml commented Nov 13, 2023

That's unusual, i expected the server properties to not be influenced by the bundled java runtime. I'd also prefer to run graalvm for my server in the long term. Switching to Hotspot seems to a possible workaround for now. Thanks for the quick help.

I'll keep this issue opened for GraalVM instead.

@cn-ml cn-ml changed the title MOTD colors displaying incorrectly MOTD colors displaying incorrectly on GraalVM Nov 13, 2023
@itzg
Copy link
Owner

itzg commented Nov 13, 2023

Agreed, there's entire compatibility suites that the JREs are supposed to comply with...but maybe properties I/O is not part of that 😀 And Oracle gets to do whatever they want with their GraalVM 😉

@itzg
Copy link
Owner

itzg commented Nov 13, 2023

That's unusual, i expected the server properties to not be influenced by the bundled java runtime

To clarify this, the mc-image-helper tool, which is used for several things including server.properties setup, is a Java app that has to use the bundled JVM.

@cn-ml
Copy link
Author

cn-ml commented Nov 13, 2023

To clarify this, the mc-image-helper tool, which is used for several things including server.properties setup, is a Java app that has to use the bundled JVM.

Ah, that's the part that i missed. I thought that that was also part of the shell scripts in the container. Thanks for the clarification.

@itzg
Copy link
Owner

itzg commented Nov 13, 2023

Ah, that's the part that i missed. I thought that that was also part of the shell scripts in the container. Thanks for the clarification.

FWIW it used to be. Re-implementing in Java opened up more features and capabilities...but didn't know I'd be dealing with incompatible Java behavior like it was the 1990's 😄 .

Copy link

This issue is stale because it has been open 30 days with no activity. Please add a comment describing the reason to keep this issue open.

@github-actions github-actions bot added the status/stale No recently activity has been seen and will be closed soon. label Dec 14, 2023
@itzg itzg added help wanted keep and removed status/stale No recently activity has been seen and will be closed soon. labels Dec 14, 2023
@MrDynamo
Copy link

Just recently switched to Graal to implement some optimizations and was confused when my MOTD broke. +1 hope there's a way to fix this in the future!

@Sculas
Copy link
Contributor

Sculas commented Dec 12, 2024

This was really bugging me and I wanted to figure out what was happening, and after some trial and error, I've figured it out.

Click here to see the reason why the issue exists.

I'm running the java21-graalvm image, which runs on Oracle Linux 8.
Doing some research, I came across this issue (NixOS/nixpkgs#260161) and PR (NixOS/nixpkgs#153457).
There, the same issue can be seen where GraalVM breaks UTF-8 characters if the locale isn't set to en_US.UTF-8.

So then, I created a Dockerfile that does the same as the PR in the hope that would fix it.

FROM itzg/minecraft-server:java21-graalvm

ENV LC_ALL en_US.UTF-8

Unfortunately, that only made things worse. I began to get tons of warnings: warning: setlocale: LC_ALL: cannot change locale
Doing some research, I found out the Oracle Linux images don't have the en_US.UTF-8 locale by default (for some reason?), as also mentioned in this issue: orbstack/orbstack#1113


So, in the end, I came up with the following solution:

  1. Create a Dockerfile next to your docker-compose.yml file with the following contents:
FROM itzg/minecraft-server:java21-graalvm

RUN dnf install glibc-langpack-en -y
ENV LC_ALL en_US.UTF-8
  1. Modify your existing docker-compose.yml to use the new Dockerfile.
services:
  minecraft:
    build: . # instead of image
    tty: true
    stdin_open: true
    # ...

It finally works now! I believe adding the RUN command to build/ol/install-packages.sh and the ENV in Dockerfile should fix the issue so that this workaround is no longer needed. I've created a PR for that: #3189

Sculas added a commit to Sculas/docker-minecraft-server that referenced this issue Dec 12, 2024
Fixes itzg#2487. Also sets `LC_ALL` to `en_US.UTF-8`.
Sculas added a commit to Sculas/docker-minecraft-server that referenced this issue Dec 12, 2024
Fixes itzg#2487. Also sets `LC_ALL` to `en_US.UTF-8`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants