Allow custom colours and hide prefix
This commit is contained in:
parent
0d443603be
commit
e2c357ccb0
@ -139,15 +139,16 @@ public enum ChatColor
|
||||
|
||||
return STRIP_COLOR_PATTERN.matcher(input).replaceAll("");
|
||||
}
|
||||
|
||||
public static String translateAlternateColorCodes(char altColorChar, String textToTranslate)
|
||||
{
|
||||
char[] b = textToTranslate.toCharArray();
|
||||
for (int i = 0; i < b.length - 1; i++)
|
||||
{
|
||||
if (b[i] == altColorChar && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i+1]) > -1)
|
||||
if (b[i] == altColorChar && "0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i + 1]) > -1)
|
||||
{
|
||||
b[i] = ChatColor.COLOR_CHAR;
|
||||
b[i+1] = Character.toLowerCase(b[i+1]);
|
||||
b[i + 1] = Character.toLowerCase(b[i + 1]);
|
||||
}
|
||||
}
|
||||
return new String(b);
|
||||
|
@ -18,15 +18,23 @@ public class CommandAlert extends Command
|
||||
}
|
||||
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
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(ChatColor.DARK_PURPLE);
|
||||
builder.append(" [Alert] ");
|
||||
if (!args[0].contains("&h")) //They want to hide the alert prefix
|
||||
{
|
||||
builder.append(ChatColor.DARK_PURPLE);
|
||||
builder.append("[Alert] "); //No space at start.
|
||||
} else
|
||||
{
|
||||
args[0].replaceAll("&h", ""); //Remove hide control code from message
|
||||
}
|
||||
|
||||
for (String s : args)
|
||||
{
|
||||
builder.append(s);
|
||||
|
||||
builder.append(ChatColor.translateAlternateColorCodes('&', s)); //Allow custom colours
|
||||
builder.append(" ");
|
||||
}
|
||||
String message = builder.substring(0, builder.length() - 1);
|
||||
|
Loading…
Reference in New Issue
Block a user