Adding a prefix after a Chat Parser did their job (so it doesn't conflict)

Discussion in 'Plugin Development' started by Tauryuu, Jan 6, 2012.

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

    Tauryuu

    Hello, I'm currently trying to add a prefix to players, but don't want to break Chat Parsers (or Managers, whatever their called). For example, I use bChatManager, and want to add something in front of the entire parsed line, like this.

    Original line with just bChatManager:
    Tauryuu: This is so cool.

    What I'm trying to do:
    [A1] Tauryuu: This is even cooler.

    And no, adding [A1] in bChatManager won't do. The plugin checks the person's rank and group in a YAML file and adds it into their chat accordingly. For example, player Tauryuu belongs into group A, rank 1. When he types into the chat, it will end up like this:
    [A1] Tauryuu: Rank 1 ftw.

    Another player, Pikushi, who belongs in group C, rank 5, will have a chat name like this:
    [C5] Pikushi: Rank 5 ftw.

    Thanks in advance.
     
  2. Have you tried using player.setDisplayName? If bChatManager properly uses display names (or you configure it like that?), it should be working. Only difference would be you wouldn't do it in PlayerChatEvent, but generally when the player gets the rank.

    Other than that, you could just use event.setMessageFormat and just prefix your string to event.getMessageFormat (the methods might be called slightly different).
     
    Tauryuu likes this.
  3. Offline

    Tster

    Just handle the event with a different priority to that of bChatManagers.
     
    Tauryuu likes this.
Thread Status:
Not open for further replies.

Share This Page