Title: Placeholder %s Not Replaced With Player Name in Broadcasted Message
MRMDevStudios opened this issue ยท 0 comments
Information
Minecraft version: 1.21.1
Modloader: NeoForge
Forge version: 21.1.93
Environment: Multiplayer Dedicated Server
Mod name: Collective + First Join Message
Mod version: collective-1.21.1-7.87.jar + firstjoinmessage-1.21.1-3.6.jar
Description
The configuration comment suggests that the string "%s" in serverBroadcastMessage is replaced by the player's username when they first join. However, the existing code does not perform this placeholder replacement. As a result, any %s inside the broadcast message appears literally in chat instead of showing the player's name.
Steps to Reproduce
Set the config to include %s, e.g. serverBroadcastMessage = "Welcome to the server, %s!".
Start the server and log in with a new player account.
Notice that the broadcast message literally shows %s instead of the player's username.
Expected Behavior
The broadcasted message should replace %s with the new player's username, e.g.:
"Welcome to the server, Steve!"
Actual Behavior
The broadcasted message still shows %s, e.g.:
Welcome to the server, %s!
Possible Fix
Manually replace %s in the code before broadcasting. For example, within the FirstSpawnEvent.java (or wherever the message is sent):
String customMessage = ConfigHandler.serverBroadcastMessage.replace("%s", player.getName().getString());
MessageFunctions.broadcastMessage(level, customMessage, colour);