itzg / docker-minecraft-server

Docker image that provides a Minecraft Server that will automatically download selected version at startup
https://docker-minecraft-server.readthedocs.io/
Apache License 2.0
9.24k stars 1.52k forks source link

MOTD colors displaying incorrectly on GraalVM #2487

Open cn-ml opened 10 months ago

cn-ml commented 10 months ago

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 commented 10 months ago

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 commented 10 months ago

...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 commented 10 months ago

...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 commented 10 months ago

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 commented 10 months ago

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 commented 10 months ago

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 commented 10 months ago

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.

itzg commented 10 months ago

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 commented 10 months ago

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 commented 10 months ago

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 commented 10 months ago

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 😄 .

github-actions[bot] commented 9 months ago

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.

MrDynamo commented 8 months ago

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!