1.16.5 Private chat channel

Discussion in 'Spigot Plugin Development' started by rokerilmitico, Jul 19, 2021.

  1. Hi I'm creating a plugin to perform the hack checks, and I would like to create a "private channel" between the controller and the controlled player regarding the chat when the player is under control, what can I do?
    Thanks in advance
  2. Listen to AsyncPlayerChatEvent, check the player, try to modify #getRecipients so it only does the controller - if fails, cancel the event and send a new message only to the controller
  3. How??
    Unfortunately, how can I do with the chat I don't know how to behave ..

    public void onPlayerChat(AsyncPlayerChatEvent e) {
    Player playerSender = e.getPlayer();
    if (ScreenshareUtil.ss.contains(playerSender)){
    //If the player is under control then the messages must only be between the controller and the controlled player
    } else {


    but I do not know how I can do it
  4. You just did... the else needs to be empty (or instead do the opposite check) and in the if just send a message to the controller using player.sendMessage()
  5. Ok, how do I get the controller ?? I did not understand this or if it is simple I am missing something
  6. wdym how you get the controller? AsyncPlayerChatEvent is only for listening chat from player to other players. so you have to have your own listening or api to get the controller yourself within inside the class and manipulate the chat from that by simply doing
    Code (Java):
    public void onChat(AsyncPlayerChatEvent e) {
       Player controller = // the controller
       e.getRecipients().clear(); // clear all the recipients
       e.getRecipients().add(// the player being controlled); // add the controlled player as a recipient of the message from the controller
  7. Yes, but how do I get the controller? Because I make a command to put the player under control, now I am working with an event as I take who executed the command this I am not understanding ..
  8. you can use a Map and get the uuid of the one being controlled as a key and put the controller's uuid as value and use it afterwards.
  9. okok .. i used an arraylist
  10. I'm not sure if that works correctly but notify us if you still have an issue.
  11. Yes, when I put the player under control I add it to the arratylist and when I finish I remove it but I don't know how I can get the controller to do this chat thing between the controller and the controlled player
  12. Strahan


    Do what he said, switch to using a Map so you can associate controller to the person being controlled.