Multiple chat colors/options?

Discussion in 'Plugin Development' started by Caprei, Oct 6, 2013.

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

    Caprei

    Hi just another quick question about chat colors... So if I wanted to make something bold AND red say, it doesn't work, here's an example of what i'm trying

    Code:java
    1. if(commandLabel.equalsIgnoreCase("heal") || commandLabel.equalsIgnoreCase("h")){
    2. if (args.length == 0){
    3. player.setHealth(20.0);
    4. player.sendMessage(ChatColor.BOLD + ChatColor.RED + "You healed yourself!");


    It doesn't work, please tell me how to do this.
    Many thanks.
     
  2. Offline

    Jogy34

    I think you may have to reverse that, so you need red first and then bold. I think I saw someone else with this problem a while ago.
     
  3. Offline

    chasechocolate

    Jogy34 that won't make a difference. It's because you can't have two non-string objects concatenated.

    Caprei use ChatColor.BOLD + "" + ChatColor.RED + "Something" or ChatColor.BOLD.toString() + ChatColor.RED + "Something".
     
  4. Offline

    Caprei

    Ahh that explains a lot thank you so much!


    Code:java
    1. player.sendMessage(ChatColor.BOLD + "You healed yourself!" + ChatColor.RED);


    That is what i'm trying currently, it still isn't working. I think I misunderstood what you meant, would you mind clarifying? Thanks. :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
  5. Offline

    chasechocolate

    Caprei the "" is just there so you aren't joining two non-string objects.
    Code:java
    1. player.sendMessage(ChatColor.BOLD + "" + ChatColor.RED + "You healed yourself!");
     
  6. Offline

    DAZ3DNDC0NFUS3D

    Change it to this
    Code:java
    1. player.sendMessage(ChatColor.BOLD + "" + ChatColor.RED + "You healed yourself!";
     
  7. Offline

    mazentheamazin

    DAZ3DNDC0NFUS3D
    This seems to work a bit better:
    Code:java
    1. player.sendMessage(ChatColor.BOLD + "" + ChatColor.RED + "You've healed yourself");

    Just made it sound a bit better and corrected DAZ3DND's Error. For the most part chase got it right.
     
  8. Offline

    Caprei

    Thanks everyone!
     
  9. Offline

    DAZ3DNDC0NFUS3D

    Lol good game. Guess I should read what I send before i send it :p
     
  10. Offline

    mazentheamazin

    Please put your suffix is solved if you don't need any more help.

    The helper just got helped??? Eh, no..
     
  11. Offline

    Caprei

    Really sorry to bother you again, but this isn't working. :(
    Code:java
    1. (ChatColor.BOLD + "" + ChatColor.RED + "You healed yourself!");
     
  12. Offline

    Goblom

    Caprei That code should work.

    Are you using it with player.sendMessage?
     
  13. Offline

    Caprei

  14. Offline

    PatoTheBest

    Btw, are you casting player to sender? (Player player = (Player) sender;)
    Code:java
    1. if(commandLabel.equalsIgnoreCase("heal") || commandLabel.equalsIgnoreCase("h")){
    2. if (args.length == 0){
    3. player.setHealth(20.0);
    4. player.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "You healed yourself!");
    5. }
    6. }
     
Thread Status:
Not open for further replies.

Share This Page