How to change chat.

Discussion in 'Plugin Development' started by Polishgaming, Jul 7, 2015.

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


    Is there a way to modify chat so a player types *message* it comes out as message?

    The first * is changed to &o for italics then the last * is the &r.

  2. Offline


    Well 1rst of all what do you imagine how it looks at the end. Or tell me what you acctually mean
  3. Offline


  4. Use the AsyncPlayerChatEvent
    Store the message with event.getMessage() as a string
    Then use
    msg = msg.replaceFirst("\\*", "§o").replaceFirst("\\*", "§r");
    It will replace the first * (\\* because its a special character in regex) with §o and then the first (the next because the first is already replaced) with §r
    Finally use event.setMessage(msg) to set the new chat message
    Last edited: Jul 7, 2015
    Polishgaming likes this.
  5. Offline


        public void onChat(AsyncPlayerChatEvent e) {
            Player p = e.getPlayer();
            String name = p.getDisplayName();
            e.setFormat(ChatColor.RED + "[ADMIN]" + ChatColor.WHITE + name + ": " + e.getMessage());
    Last edited: Jul 7, 2015
  6. why did you do that?
    it has no relevance and
Thread Status:
Not open for further replies.

Share This Page