Allow custom colours and hide prefix

This commit is contained in:
lol768 2012-10-21 22:41:17 +02:00 committed by md_5
parent 0d443603be
commit e2c357ccb0
2 changed files with 17 additions and 8 deletions

View File

@ -139,6 +139,7 @@ public enum ChatColor
return STRIP_COLOR_PATTERN.matcher(input).replaceAll(""); return STRIP_COLOR_PATTERN.matcher(input).replaceAll("");
} }
public static String translateAlternateColorCodes(char altColorChar, String textToTranslate) public static String translateAlternateColorCodes(char altColorChar, String textToTranslate)
{ {
char[] b = textToTranslate.toCharArray(); char[] b = textToTranslate.toCharArray();

View File

@ -18,15 +18,23 @@ public class CommandAlert extends Command
} }
if (args.length == 0) if (args.length == 0)
{ {
sender.sendMessage(ChatColor.RED + "Please follow this command by an announcement to make"); sender.sendMessage(ChatColor.RED + "You must supply a message.");
} else } else
{ {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
if (!args[0].contains("&h")) //They want to hide the alert prefix
{
builder.append(ChatColor.DARK_PURPLE); builder.append(ChatColor.DARK_PURPLE);
builder.append(" [Alert] "); builder.append("[Alert] "); //No space at start.
} else
{
args[0].replaceAll("&h", ""); //Remove hide control code from message
}
for (String s : args) for (String s : args)
{ {
builder.append(s);
builder.append(ChatColor.translateAlternateColorCodes('&', s)); //Allow custom colours
builder.append(" "); builder.append(" ");
} }
String message = builder.substring(0, builder.length() - 1); String message = builder.substring(0, builder.length() - 1);