PaperMC / Paper

The most widely used, high performance Minecraft server that aims to fix gameplay and mechanics inconsistencies
https://papermc.io/
Other
10.04k stars 2.34k forks source link

AsyncPlayerChatEvent#setFormat() #8863

Closed maurxce closed 1 year ago

maurxce commented 1 year ago

Expected behavior

When you set a custom chat format, the console should also use the format to log message details (player, message)

Observed/Actual behavior

The console only logs the player's message and not their name

Steps/models to reproduce

  1. Create a new Spigot plugin
  2. Creata an EventHandler to set a custom chat format
@EventHandler
public void onChat(AsyncPlayerChatEvent e) {
  String format = "{username}: {message}";
  format = format.replace("{username}", "%1$s").replace("{message}", "%2$s");
  e.setFormat(format);
}

Plugin and Datapack List

Just this one custom plugin with only the custom chat format

Paper version

This server is running Paper version git-Paper-404 (MC: 1.19.3) (Implementing API version 1.19.3-R0.1-SNAPSHOT) (Git: f9dc371) You are running the latest version Previous version: git-Purpur-1908 (MC: 1.19.3)

Other

No response

lynxplay commented 1 year ago

Replicable and caused by the way the server handles signed/unsigned messages. The changed format is only tracked in the unsigned part of the message, however the server only logs the signed part of the message.

See: https://github.com/PaperMC/Paper/blob/f9dc371fd8c56f1ad1359fc3bf1f7a40921ec66f/patches/server/0010-Adventure.patch#L520

and

https://github.com/PaperMC/Paper/blob/f9dc371fd8c56f1ad1359fc3bf1f7a40921ec66f/patches/server/0010-Adventure.patch#L2503.

Notably, we are currently not passing an unsignedFunction value here, as well, the message is viewer unaware, hence this is just Component.literal of the signed message.