#Using display name in death messages
1 messages · Page 1 of 1 (latest)
hi commandgeek
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event) {
event.setDeathMessage(event.getEntity().getDisplayName());
}
Something like this you mean?
Use .replace() on the event.getDeathMessage() and use their name and display name.
And just set it to that
I considered that, but in the rare case that the user has a username that shows up elsewhere in the death message (e.g. if their name was "pricked" and the message was "pricked was pricked to death") it might get messed up and replace both instances
didnt know u used spigot i thought u just did datapacks
I'm trying to learn :)
Well, but that'd still be correct. If their username was "Pricked", the death message would still be "Pricked was pricked to death"
oh
Actually, as long as every death message begins with the player's name, all I have to do is replace the first time it appears
I guess I gotta find every death message in the game :P
Mhm, just make sure that no death message repeats their username.
oh true
I'm sure that's on the Wiki somewhere.
And you could handle the outliers manually
i had to do that once for a plugin that made people go to spectator when they died instead of the death screen
it sucked
oh wait I just realised, in all the cases where there is a second name (e.g. "player1 was shot by player2"), I want all the names to be replaced with display-names, including the second player....
that becomes harder
not necessarily, its just like player1.getDisplayName() + " was shot by " + player2.getDisplayName()
ignore my weird + string formatting but ye basically that
You could iterate through all the online players, and replace any instance of their name with their display name.
Should fix that issue.
No problem, good luck!