Sending different colored messages to different players

Discussion in 'Plugin Development' started by MCCoding, Jun 5, 2014.

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

    MCCoding

    Hey i'm wondering how I can send different colored messages to different types of people, I have made a party plugin and what I'm trying to do is change there name color so if they are in my party and they send a message in chat their name will be red, if they are the party leader their name will be green and if they are not in my party it will appear as normal grey how would i do this?
     
  2. Offline

    fireblast709

    if statements and separate sendMessage calls / String formats?
     
  3. Offline

    MCCoding

    fireblast709

    I did have string formats like this but it didn't work it would just send everyone the return ChatColor.DARK_RED + getPartyName(player.getName()) + ChatColor.RED + " " + player.getName() + ": " + ChatColor.WHITE;

    Code:java
    1. public String getPartyFormat(Player player, Player[] players) {
    2. if(isInParty(player.getName()) == false) {
    3. return ChatColor.DARK_GREEN + player.getName() + ": " + ChatColor.GREEN;
    4. } else {
    5. for(Player online : players) {
    6. if(getPartyName(player.getName()).equalsIgnoreCase(getPartyName(online.getName()))) {
    7. return ChatColor.DARK_RED + getPartyName(player.getName()) + ChatColor.RED + " " + player.getName() + ": " + ChatColor.WHITE;
    8.  
    9. } else {
    10. return ChatColor.DARK_GREEN + getPartyName(player.getName()) + ChatColor.GREEN + " " + player.getName() + ": " + ChatColor.WHITE;
    11. }
    12. }
    13. }
    14. return ChatColor.DARK_GREEN + player.getName() + ": " + ChatColor.GREEN;
    15. }
     
  4. Offline

    fireblast709

    for loop + insta return doesn't work well you need to loop over the players, get the specific format per player, and the send a message to that player, using that format MCCoding
     
Thread Status:
Not open for further replies.

Share This Page