Hide the chat for a player?

Discussion in 'Plugin Development' started by Soxra, Feb 9, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    Soxra

    Hi,
    i want to disallow a player to see the chat and to use the chat, i don't think its too difficult, but i'm on the right track. Please help me :)
     
  2. Offline

    Tirelessly

    You could spam them with blanks to clear the chat, remove them from the recipients list on AsyncPlayerChatEvent, and cancel their own AsyncPlayerChatEvent
     
  3. Offline

    caseif

    <Edit by Moderator: Redacted bit url>
     
    Last edited by a moderator: Feb 17, 2017
  4. Offline

    Soxra

    I already Google it
     
  5. Offline

    RealDope

    There's an option in the client for them to disable chat lol... (or maybe that's only nodus? unsure)

    But if you want to do it server side, use the ASyncPlayerChatEvent, and cancel it, but then loop through everyone who you want to get the message and send it to them.
     
  6. Offline

    Soxra

    Ans how to keep Thema [Admin] Hand color etc.?
     
  7. Soxra
    Just remove the player from the recipients and they will not get the message... the first 2 replies already told you this but apparently you're ignoring.
     
  8. Offline

    RealDope

    event.getPlayer().getDisplayName();
     
  9. Offline

    Soxra

    And how to add the player After a period of time again ? Becuase this ins only avaiable in the playerchatevent.
     
  10. You're removing them each time a message is sent so when you want them to see the chat again just stop removing them.

    Basically you'd need a Set<String> for player names where you store the players banned from chatting and in the event check if event.getPlayer().getName() is in that set, if he is cancel the event, otherwise remove him from the recipients list.
     
  11. Offline

    Soxra

    Do i need to add the player again?

    But how to remove him from the list?
    Eg:
    onPlayerChat(AsyncPlayerChatEvent event)
    if bannedPlayers.contains(player.getName())
    event.getRecipients().remove(player)
    event.setCancelled(true)

    and then? And how to remove the player if he is not chatting? He should be banned from the chat when he logins.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  12. Offline

    Tirelessly

    onPlayerChat(AsyncPlayerChatEvent)
    if sender is banned
    cancel
    else
    for each banned player
    if they're on the recipients list
    remove them from the recipients list
     
  13. Offline

    chasechocolate

    Nope, that's Vanilla Minecraft.
     
Thread Status:
Not open for further replies.

Share This Page