kangarko / ChatControl-Red

Issue tracker and documentation for the next generation ChatControl Red, the most advanced chat management plugin.
43 stars 22 forks source link

1.20.4: Unable to prevent message events from being sent to hidden players #2730

Open Hackerokuz opened 4 days ago

Hackerokuz commented 4 days ago

"/version ChatControlRed" - plugin version

10.25.5

Are you using MySQL?

No

Are you using BungeeCord?

No

Error log (if applicable)

No response

"/chc debug" output (strongly recommended)

debug.zip

Information about the issue/bug

There is a bug in chat control red preventing events from being cancelled for hidden players.

Currently I need to hide a player while they are in a tutorial from other players. When I do so with hidePlayer function I cant prevent chat messages from going to the player in the event.

I have tried ChatChannelEvent and AsyncPlayerChatEvent Tried each of them with EventPriority.HIGH and EventPriority.HIGHEST

I do

event.getRecipients().removeIf(player -> {
    TutorialController innerController = plugin.inTutorial.get(player.getUniqueId());
    if (innerController != null) {
        return innerController.getTutorial().isChatBlocked();
    }
    return false;
});

I have also tried event.getRecipients().clear(); just to see if it does anything but hidden player still receives messages anyway.

I cant find anything in settings file related to hidden players.

I also tried changing Chat_Listener_Priority.

Behavior stays the same.

Example situation

If lets say player1 sends "hi" in chat and I have player2 in a tutorial.

I want to make sure that from player1 perspective player2 is not visible at all. From player2 perspective I want to hide "hi" message when player1 sends it.

if I do not use the hidePlayer function then removing player2 from recipients works fine.

However if player2 is hidden from player1 with hidePlayer function. Recipients doesn't contain player2 to begin with. Player2 still receives the message even though in the events recipients player2 was never included.

I think its an issue with chatcontrol-red because it performs as expected without that plugin.