mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-04 06:28:53 +00:00
Fix color parsing, fixes #34
This commit is contained in:
1 parent
cf946b332f
commit
5a8f3f5a81
1 file changed
+7
-11
@@ -126,10 +126,12 @@ public class CarbonChatChannel extends ChatChannel {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TextColor targetColor = getColor(target);
|
||||||
|
|
||||||
TextComponent formattedMessage = (TextComponent) carbonChat.getAdventureManager().processMessage(formatEvent.getFormat(),
|
TextComponent formattedMessage = (TextComponent) carbonChat.getAdventureManager().processMessage(formatEvent.getFormat(),
|
||||||
"br", "\n",
|
"br", "\n",
|
||||||
"displayname", displayName,
|
"displayname", displayName,
|
||||||
"color", "<" + getColor(target).asHexString() + ">",
|
"color", "<" + targetColor.asHexString() + ">",
|
||||||
"phase", Long.toString(System.currentTimeMillis() % 25),
|
"phase", Long.toString(System.currentTimeMillis() % 25),
|
||||||
"server", carbonChat.getConfig().getString("server-name", "Server"),
|
"server", carbonChat.getConfig().getString("server-name", "Server"),
|
||||||
"message", formatEvent.getMessage());
|
"message", formatEvent.getMessage());
|
||||||
@@ -138,7 +140,7 @@ public class CarbonChatChannel extends ChatChannel {
|
|||||||
String prefix = processPlaceholders(user, carbonChat.getConfig().getString("spy-prefix"));
|
String prefix = processPlaceholders(user, carbonChat.getConfig().getString("spy-prefix"));
|
||||||
|
|
||||||
formattedMessage = (TextComponent) MiniMessage.get().parse(prefix, "color",
|
formattedMessage = (TextComponent) MiniMessage.get().parse(prefix, "color",
|
||||||
getColor(target).asHexString()).append(formattedMessage);
|
targetColor.asHexString()).append(formattedMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatComponentEvent newEvent = new ChatComponentEvent(user, target, this, formattedMessage,
|
ChatComponentEvent newEvent = new ChatComponentEvent(user, target, this, formattedMessage,
|
||||||
@@ -342,16 +344,10 @@ public class CarbonChatChannel extends ChatChannel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (color.startsWith("&")) {
|
if (color.contains("&") || color.contains("§")) {
|
||||||
LegacyFormat legacyFormat = LegacyComponentSerializer.parseChar(color.charAt(1));
|
color = color.replace("&", "§");
|
||||||
|
|
||||||
if (legacyFormat != null) {
|
return LegacyComponentSerializer.legacySection().deserialize(color).color();
|
||||||
TextColor legacyColor = legacyFormat.color();
|
|
||||||
|
|
||||||
if (legacyColor != null) {
|
|
||||||
return legacyColor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TextColor textColor = TextColor.fromHexString(color);
|
TextColor textColor = TextColor.fromHexString(color);
|
||||||
|
|||||||
Reference in new issue
Block a user