fix: chatcolor now works when player doesn't use color codes
This commit is contained in:
parent
5c1230bc16
commit
c6442bc88f
1 changed files with 13 additions and 5 deletions
|
|
@ -167,14 +167,22 @@ public class ChatFormatter {
|
||||||
// Заменяем смайлики
|
// Заменяем смайлики
|
||||||
result = replaceEmojis(result, player);
|
result = replaceEmojis(result, player);
|
||||||
|
|
||||||
// Если есть право на цвета - конвертируем
|
// Проверяем есть ли цветовые коды в сообщении
|
||||||
if (hasColorPermission) {
|
boolean hasColorCodes = LEGACY_COLOR_PATTERN.matcher(result).find()
|
||||||
|
|| SECTION_COLOR_PATTERN.matcher(result).find()
|
||||||
|
|| HEX_PATTERN.matcher(result).find()
|
||||||
|
|| MINIMESSAGE_HEX_PATTERN.matcher(result).find();
|
||||||
|
|
||||||
|
// Если есть право на цвета И есть цветовые коды - конвертируем
|
||||||
|
if (hasColorPermission && hasColorCodes) {
|
||||||
result = convertAllColors(result);
|
result = convertAllColors(result);
|
||||||
} else {
|
} else {
|
||||||
// Убираем цветовые коды
|
// Убираем цветовые коды если нет прав
|
||||||
result = stripLegacyColors(result);
|
if (!hasColorPermission) {
|
||||||
|
result = stripLegacyColors(result);
|
||||||
|
}
|
||||||
|
|
||||||
// Применяем цвет чата если установлен
|
// Применяем цвет чата если установлен (когда нет своих цветов)
|
||||||
LoChat plugin = LoChat.getInstance();
|
LoChat plugin = LoChat.getInstance();
|
||||||
if (plugin != null && plugin.getChatColorManager() != null) {
|
if (plugin != null && plugin.getChatColorManager() != null) {
|
||||||
result = plugin.getChatColorManager().applyChatColor(player.getUniqueId(), result);
|
result = plugin.getChatColorManager().applyChatColor(player.getUniqueId(), result);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue