How does factions do it? | Chat Formatting

Discussion in 'Spigot Plugin Development' started by InfiniteIV, May 17, 2015.

  1. I'm redoing the way I format my chat in my server since factions creates a bug for it. However, how does factions format the chat and have every player see the chat differently? (Like the faction is red, green, orange or purple)? The way I done it was cancel the event and just message the players the format but I want to know how to do it with e#setFormat()
     
  2. If I understand what you're asking, Which I think I do, It's actually pretty easy. Factions uses a chat modifier called relcolor, Which is used to alter the color of different clans in chat. Based upon if the clan is an ally, enemy or, neutral.

    You don't need to cancel the event, Just call setFormat on it after you modify the format.
     
  3. But how does it use a different colour for every player, wouldn't setFormat make it for all players?
     
  4. Presumably, The plugin grabs a list of online recipients, Then iterates over that list an formats the message per player. Giving it more thought now, It probably does cancel the main chat event and, Sends individual messages to each player. Replacing the color of the sending players faction with the appropriate ally/enemy/neutral relation color.
     
  5. It doesn't, my plugin did that and this is what happens
    [​IMG]
    (Don't be fooled, the faction isn't there cuz I've disabled it in the config but the event is not cancelled anymore)