/ess version -
[INFO] Server version: 1.8.8-R0.1-SNAPSHOT git-Spigot-21fe707-e1ebe52 (MC: 1.8.8)
[INFO] EssentialsX version: 2.17.2.0
[INFO] PlaceholderAPI version: 2.10.4
[INFO] LuckPerms version: 5.0.72
[INFO] Vault version: 1.7.2-b107
[INFO] Citizens version: 2.0.16-SNAPSHOT (build 1267)
[INFO] EssentialsXChat version: 2.17.2.0
[INFO] EssentialsXSpawn version: 2.17.2.0
Issue Description: When I have socialspy enabled and someone talks on the chat, being out of the chat-radius, his displayname gets bugged and it literally replaces with my displayname.
Screenshot:

Could you please also provide your config and server startup log as the template asks? I can't reproduce this on my end.
Hello again!
Sorry for bringing poor information about the bug, I was a little busy. Today I have been 2 entire hours making a deep investigation on this bug on a new empty server, and I figure it out a lot of things.
The first thing I have to noticed, is that the bug doesn't actually comes entirely from Essentials, and now I'm confused about considering this a bug or not, maybe it is likely more a conflict problem that was actually fixed by Essentials, but not fully fixed (you will understand it after reading the How to reproduce the bug)
How to reproduce the bug, step-by-step

So, after following those steps, you will notice this results:

The name I used for the one that is OP and will spy the messages is "Tomi010817", and for the one that will send the messages, is "Test".
As you can see, when "Test" sent a raw message as Local, and "Tomi010817" was out of his chat-radius, "Tomi010817" didn't have other alternative of spying the local message, so you can clearly see that the placeholder on the Spy Local format "[L][SPY]" gets bugged, showing the name of the one who spies it (in this case Tomi010817). This also happens with other placeholders intended to show stuff owned by "Test" instead of "Tomi010817" (for example his Rank, I will attach an extra example image of the bug including group ranks also, at the end of the reply)
I think that this should be fixed by Essentials and not by other plugin author, because Essentials has already fixed this problem with the Local format "[L]" and with the Shout format "[Shout]" (you can see on the image above that the bug doesn't occur with those chat formats) So I will guess that Essentials only forgot to also fix this problem with the [L][Spy] chat format.
Below this, I will also bring you the same example but also using group ranks.

The last message sent by "Test" on both example images, is the same message but "Tomi010817" is inside the chat-radius of "Test", so "Tomi010817" doesn't have any need to spy the message, and you can see that that format is fixed.
In short words, Essentials maybe forgot to also fix the compatibility with ChatInyector, on the Local Spy "[L][Spy]" chat format.
Hope you can read this, and if you could, thank you very much for taking the time of reading this long text. 馃挏 if you want more detailed info about the problem, or even join the server and see the bug with me, you can add me on discord: Tomi010817#8699
So the issue is that player_name doesnt reference target player name but self. Is it possible that this switch case here is your target?
@Override public MessageResponse sendMessage(IMessageRecipient recipient, String message)
Invokation looks like
line # 113
LocalChatSpyEvent spyEvent = new LocalChatSpyEvent(event.isAsynchronous(), event.getPlayer(), format, event.getMessage(), spyList);
server.getPluginManager().callEvent(spyEvent);
if (!spyEvent.isCancelled()) {
for (Player onlinePlayer : spyEvent.getRecipients()) {
onlinePlayer.sendMessage(String.format(spyEvent.getFormat(), user.getDisplayName(), spyEvent.getMessage()));
}
}
I don't know nor understand about java xD, but It seems very well done, also thanks for looking for a solution to this! :D
{player_name} is a PlaceholderAPI placeholder, not an EssentialsX Chat one. ChatInjector is responsible for replacing PAPI placeholders, and depending on the context it might not know which player the placeholder is supposed to be calculated from. I'll investigate this further when I get a chance, but I suspect the way to fix this is to use EssentialsX Chat placeholders only.
Hey md678685! Thankyou so much for answering.
Yes, I know that PAPI plugin author should be responsible for the placeholders, but since the problem only occurs on that mentioned chat format, I believe that you could be able to fix it someway, since all the other chat formats work perfectly. I will wait until you have the chance to investigate more into this. Please tell me any news!
PD: I also know that one of the ways to fix it would be only using the EssentialsChat placeholders, but I'm persistent on wanting that feature on my server which would show the player its realname when he is on a group where the placeholder isn't {DISPLAYNAME} and is {player_name}. One example would be on staff groups to always show their realname.
You can use the {USERNAME} placeholder from EssentialsX Chat to include the player's real name in the chat format. EssentialsX does not have anything to do with {player_name}; that is an issue with either ChatInjector or PlaceholderAPI.