AsyncPlayerChatEvent

Discussion in 'Plugin Development' started by Yehonathan_, Apr 19, 2017.

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

    Yehonathan_

    Hello folks,
    I am wondering if its possible to change a players format name instead of changing everyones? I have a plugin which lets you change your chat color but its also applied for everyone else on the server :( If anyone has any idea of how i can code this it would be amazing!
     
  2. Offline

    MCMastery

    So like you want to be able to give certain players permission to chat with color?

    If that's the case, just check if they have the permission (evt.getPlayer().hasPermission("permission.name"))
     
  3. Offline

    Zombie_Striker

    @Yehonathan_
    1. Create a hashmap. The keys will be UUIDs, and the values will be a String or a chatcolor. This represents the format the players want. Use the String if you also want them to customize their name /brackets, and use the chatcolor if you just want to change the color.
    2. When a player wants to change their text, either provide the full message to the map, or translate the color code to a ChatColor and store that in the hashmap.
    3. When a player types something in chat, either set the format equal to the string, or just add the chatcolor.
    4. Remember to save the hashmap to the config in the onDisable, and re-load it from the config in the onEnable.
     
  4. Offline

    Yehonathan_

    Well in my case i have a GUI, so when a player types /cc it opens a GUI and lets the player chose a certain color. I dont use commands like /cc set <player> red

    Ill give it a try! Thanks for all the answers :)
    1 more question tho,
    (2) If i want to change a players text should i use event.setFormat()? @Zombie_Striker

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    MCMastery likes this.
  5. Offline

    Caderape2

    @Yehonathan_
    event.getFormat, it's for everything before the message. If you want change the text, use event.getMessage
     
    Yehonathan_ likes this.
  6. Offline

    Yehonathan_

    Ill give it a try thanks for the answer!

    Sent fra min GT-I9195 via Tapatalk
     
Thread Status:
Not open for further replies.

Share This Page