EssentialsX

EssentialsX

2M Downloads

EssentialsChat, Socialspy chat format shows your prefix when players talk out of chat-radius

Tomi010817 opened this issue ยท 7 comments

commented

/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:
2020-03-02_09 27 54

commented

Could you please also provide your config and server startup log as the template asks? I can't reproduce this on my end.

commented

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

  • You will need the following 6 plugins (Vault, EssentialsX, EssentialsXChat, ChatInyector and its dependencies: PlaceHolderAPI and ProtocolLib) *Forget about LuckPerms, I used it for letting "Test" shout a message to demostrate you that the format [Shout] is already fixed.
    2020-03-05_11 17 36
  • After having the 6 plugins downloaded, you must download Player expansion for PlaceHolderAPI with /papi ecloud download Player. Then, the only thing you need to change on the config.yml of Essentials is on the EssentialsChat section. You must enable the radius chat, changing it from 0 to any number higher than it (in my case: 100 blocks).
  • On the "format:" you must change it from "<{DISPLAYNAME}> {MESSAGE}" to "<{player_name}> {MESSAGE}" and here it comes the big question, "Why would you change the displayname variable with player_name?" Well, first of all, remember this is the fastest way to reproduce the bug, but on my detailed server I use it for avoiding players who used to be Vip group with their nickname changed, to show their realname whenever their Vip group would expire, or also to obligate players with staff groups inherited, to always show their real name, even if before becoming staff they had a custom nickname defined. There are a lot more reasons about this, but I won't be splashing much more on this, as it's not the topic.
  • You can now restart the server. And after you do, you will need to join the server with two differrent accounts for obviously reasons. One of them will need to have OP so that way you can "Spy" the messages sent by the other account when it is out of the chat-radius.

So, after following those steps, you will notice this results:
2020-03-05_11 17 28
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.
2020-03-05_11 09 25
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

commented

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)

https://github.com/EssentialsX/Essentials/blob/d3cee314c6ac8e7b8974b63ecefc9a257f13144a/Essentials/src/com/earth2me/essentials/messaging/SimpleMessageRecipient.java`

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()));
            }
        }

https://github.com/EssentialsX/Essentials/blob/347179373d20b8a591a9856b198d998c8ea2a82e/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerNormal.java

commented

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

commented

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

commented

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.

commented

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.