add support for & color codes in discord
This commit is contained in:
parent
84a984f2f6
commit
369c770398
2 changed files with 15 additions and 7 deletions
6
pom.xml
6
pom.xml
|
@ -114,6 +114,12 @@
|
|||
<artifactId>joda-time</artifactId>
|
||||
<version>2.12.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-serializer-legacy</artifactId>
|
||||
<version>4.13.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -18,6 +18,7 @@ import net.kyori.adventure.text.Component;
|
|||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -155,17 +156,18 @@ public class DiscordPlugin {
|
|||
)
|
||||
.clickEvent(ClickEvent.openUrl(discordUrl));
|
||||
|
||||
final Component deserialized = LegacyComponentSerializer.legacyAmpersand().deserialize(message.replace("\uD83D\uDC80", "☠"));
|
||||
|
||||
final Component messageComponent = Component
|
||||
.text("")
|
||||
.color(NamedTextColor.GRAY)
|
||||
.append(deserialized.append(attachmentsComponent));
|
||||
|
||||
final Component component = Component.translatable(
|
||||
"[%s] %s › %s",
|
||||
discordComponent,
|
||||
nameComponent,
|
||||
Component
|
||||
.text(
|
||||
message
|
||||
.replace("\uD83D\uDC80", "☠")
|
||||
)
|
||||
.color(NamedTextColor.GRAY)
|
||||
.append(attachmentsComponent)
|
||||
messageComponent
|
||||
).color(NamedTextColor.DARK_GRAY);
|
||||
bot.chat().tellraw(component);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue