Solved HELP - Make Global and Spectator Chat - Spigot 1.8.8

Discussion in 'Spigot Plugin Development' started by Seeyko, May 20, 2017.

  1. Hello all,

    So for my mini-games i want to make a global and a spectator chat (when a player is dead, the other player who are alive can't see is message, but only other dead player can talk between them).

    I knew i have to do stuff with event.getrecipients() and remove players from this but i really don't understand how this works... And i didn't find any tutorials on it.. Only changing format of the chat but not how to create separate channel :/

    So if someone can explains it to me (even without spoonfeeding and without code but tell me how recipients work) it will be really useful for me !

    Thanks and have a good day.

    Ps: Sorry for my english..
  2. You could have two lists of players called Dead and Alive. When a player dies remove them from the alive list and add them to the dead list. When a player sends a message use the chat even (believe is is AsyncPlayerChatEvent) and cancel the chat. After you have cancelled the chat check which list the player is in. If they are in Dead use a for loop to send all players in the Dead list a message (p.sendMessage) the same for the alive list of the sender is alive. If you need more explanation just ask!
  3. The easiest way would be to just cancel the AsyncPlayerChatEvent and then send the message (#getMessage) to the players who should receive it.

    EDIT: Sniped :p
    • Agree Agree x 1
  4. Oh ok ! I dont know why i didn t think of this before...

    Thanks you both !
  5. You most welcome! Have fun coding your plugin
  6. You also don't need two lists. Just one. Perhaps an alive list. Then remove them from that list when they die. Use List#contains to check.

    Sent from my iPhone using Tapatalk
    • Agree Agree x 1