Yes it's me again... I was expecting to be able to concat() a ChatColor.COLOUR to a string but evidently not. What is the done thing for doing this?
Chinwe Awesome! Thanks Chinwe I'm using this code, but its throwing a NullPointerException error. I'm iterating through all the chars in the char array (which was converted from a string). If theres a & then it looks for the next char and if its a correct number it concats the (ChatColor.COLOUR).toString to a new string. Otherwise it just concats the char. Code:java for (int i = 0; i < message.length; i++){ if (message[i] == '&'){ switch (message[i + 1]){ case 'b': newMessage.concat((ChatColor.AQUA).toString()); case '0': newMessage.concat((ChatColor.BLACK).toString()); case '9': newMessage.concat((ChatColor.BLUE).toString()); case '3': newMessage.concat((ChatColor.DARK_AQUA).toString()); case '1': newMessage.concat((ChatColor.DARK_BLUE).toString()); case '8': newMessage.concat((ChatColor.DARK_GRAY).toString()); case '2': newMessage.concat((ChatColor.DARK_GREEN).toString()); case '5': newMessage.concat((ChatColor.DARK_PURPLE).toString()); case '4': newMessage.concat((ChatColor.DARK_RED).toString()); case '6': newMessage.concat((ChatColor.GOLD).toString()); case '7': newMessage.concat((ChatColor.GRAY).toString()); case 'a': newMessage.concat((ChatColor.GREEN).toString()); case 'd': newMessage.concat((ChatColor.LIGHT_PURPLE).toString()); case 'c': newMessage.concat((ChatColor.RED).toString()); case 'f': newMessage.concat((ChatColor.WHITE).toString()); case 'e': newMessage.concat((ChatColor.YELLOW).toString()); case 'm': newMessage.concat((ChatColor.STRIKETHROUGH).toString()); case 'l': newMessage.concat((ChatColor.BOLD).toString()); case 'k': newMessage.concat((ChatColor.MAGIC).toString()); case 'n': newMessage.concat((ChatColor.UNDERLINE).toString()); case 'o': newMessage.concat((ChatColor.ITALIC).toString()); } } else { newMessage.concat(Character.toString(message[i])); } } player.sendMessage(newMessage);[/i][/i] EDIT by Moderator: merged posts, please use the edit button instead of double posting.
Eeeeh what are you trying to do? Convert all &[char] to a ColorCode? If so, use Code: String translatedMessage = ChatColor.translateAlternateColorCodes('&', originalMessage);