Chat Questions

Discussion in 'Plugin Development' started by JPG2000, Oct 31, 2013.

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

    JPG2000

    Im looking to make a ChatManager.

    I have acouple of questions:

    What would be the best way to change what the message looks like? (IE, changing the < before name, etc)? Would it be cancelling the event and broadcasting it?

    What does add reciptient and remove do?


    Thanks!
     
  2. Offline

    theearlypc423

    Use a modify format thing and put it in your config.yml, then you can edit the chat so it looks however you like.
     
  3. Offline

    JPG2000

    theearlypc423 So, basicly, cancel the event and broadcast? Or is there a format method?
     
  4. Offline

    theearlypc423

    Last time I checked you cant cancel. And doing broadcast would be bad because you wouldn't mute people. In the bukkit javadocs there is a very good example of formatting chat.
     
  5. Offline

    JPG2000

  6. Offline

    theearlypc423

    jd.bukkit.org
     
  7. Offline

    mattrick

    I'm fairly certain you can cancel the chat event. How would plugins that stop you from chatting do stuff like that?
     
    JPG2000 likes this.
  8. Offline

    tommykins20

    They way I do chat stuff is do event.setFormat and the first occurance of %s is the player's name (who chatted) and the second occurance of %s is the message.
    Recepients is the players that receive the message.
     
  9. Offline

    MCCoding

    mattrick16 JPG2000
    You can cancel the AsyncPlayerChatEvent, as for setting the format and stuff use

    Code:
    event.setFormat(ChatColor.RED + "Admin " + ChatColor.GREEN + player.getName() + ChatColor.WHITE + event.getMessage())
    If you want to be able to set custom prefixes/suffix just get the sting from the config.yml and add it to the format function.
     
    whitehooder likes this.
  10. Offline

    JPG2000

    MCCoding Thank you.

    I know java, I just didn't know there was a setFormat method, or what I did. Thanks.
     
  11. Offline

    whitehooder

    Which is why he showed you it with example code.
     
    JPG2000 likes this.
Thread Status:
Not open for further replies.

Share This Page