support for hex color codes

This commit is contained in:
speedxx 2020-07-11 23:34:30 -04:00
parent 07308de38d
commit 66ff1fc2b5
5 changed files with 23 additions and 6 deletions

View file

@ -39,7 +39,7 @@ public class DisbandGuildCommand implements CommandExecutor
if (args.length == 0) if (args.length == 0)
{ {
player.sendMessage(ChatColor.RED + "Are you sure you want to delete your guild? Type 'CONFIRM' to continue."); player.sendMessage(ChatColor.RED + "Are you sure you want to delete your guild? Type '/disbandguild CONFIRM' or '/deleteguild CONFIRM' to continue.");
return true; return true;
} }

View file

@ -50,8 +50,8 @@ public class GuildTagCommand extends GBase implements CommandExecutor
tag = tag.replace("%tag%", guild); tag = tag.replace("%tag%", guild);
GUtil.setTag(GUtil.color(tag) + " ", guild); GUtil.setTag(GUtil.translateHexColorCodes(tag) + " ", guild);
player.sendMessage(ChatColor.GREEN + "Guild tag set to \"" + GUtil.color(tag) + ChatColor.GREEN + "\""); player.sendMessage(ChatColor.GREEN + "Guild tag set to \"" + GUtil.translateHexColorCodes(tag) + ChatColor.GREEN + "\"");
return true; return true;
} }
} }

View file

@ -41,7 +41,7 @@ public class LeaveGuildCommand extends GBase implements CommandExecutor
if (args.length == 0) if (args.length == 0)
{ {
player.sendMessage(ChatColor.RED + "Are you sure you want to leave your guild? Type 'CONFIRM' to continue."); player.sendMessage(ChatColor.RED + "Are you sure you want to leave your guild? Type '/leaveguild CONFIRM' or '/guildleave CONFIRM' to continue.");
return true; return true;
} }

View file

@ -15,6 +15,8 @@ import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class GUtil public class GUtil
{ {
@ -229,4 +231,19 @@ public class GUtil
{ {
return ChatColor.translateAlternateColorCodes('&', s); return ChatColor.translateAlternateColorCodes('&', s);
} }
public static String translateHexColorCodes(String message)
{
Pattern pattern = Pattern.compile("&#[a-f0-9A-F]{6}");
Matcher matcher = pattern.matcher(message);
while (matcher.find())
{
String color = matcher.group().replace("&", "");
message = message.replace("&" + color, net.md_5.bungee.api.ChatColor.of(color) + "");
}
message = ChatColor.translateAlternateColorCodes('&', message);
return message;
}
} }

View file

@ -24,7 +24,7 @@ commands:
aliases: [gchat] aliases: [gchat]
disbandguild: disbandguild:
description: Deletes your guild description: Deletes your guild
usage: /<command> usage: /<command> <confirm>
aliases: [deleteguild] aliases: [deleteguild]
guildteleport: guildteleport:
description: Teleport to other guild members description: Teleport to other guild members
@ -36,7 +36,7 @@ commands:
aliases: [guildinvite] aliases: [guildinvite]
leaveguild: leaveguild:
description: Leave your guild description: Leave your guild
usage: /<command> usage: /<command> <confirm>
aliases: [guildleave] aliases: [guildleave]
guildkick: guildkick:
description: Kicks a player from the guild description: Kicks a player from the guild