[FEAT] MiniMessage formatting support
This commit is contained in:
@@ -6,6 +6,7 @@ import com.hypherionmc.craterlib.nojang.resources.ResourceIdentifier;
|
||||
import me.hypherionmc.mcdiscordformatter.discord.DiscordSerializer;
|
||||
import me.hypherionmc.mcdiscordformatter.minecraft.MinecraftSerializer;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.json.JSONOptions;
|
||||
import net.minecraft.ChatFormatting;
|
||||
@@ -23,6 +24,8 @@ public class ChatUtils {
|
||||
JSONOptions.byDataVersion().at(SharedConstants.getCurrentVersion().getDataVersion().getVersion())
|
||||
).build();
|
||||
|
||||
private static final MiniMessage miniMessage = MiniMessage.miniMessage();
|
||||
|
||||
public static Component adventureToMojang(net.kyori.adventure.text.Component inComponent) {
|
||||
final String serialised = adventureSerializer.serialize(inComponent);
|
||||
return Component.Serializer.fromJson(serialised, getRegistryLookup());
|
||||
@@ -109,7 +112,8 @@ public class ChatUtils {
|
||||
}
|
||||
|
||||
public static net.kyori.adventure.text.Component format(String value) {
|
||||
return net.kyori.adventure.text.Component.translatable(convertFormattingCodes(value));
|
||||
value = convertFormattingCodes(value);
|
||||
return miniMessage.deserializeOr(value, net.kyori.adventure.text.Component.translatable(value));
|
||||
}
|
||||
|
||||
private static String convertFormattingCodes(String input) {
|
||||
|
@@ -62,6 +62,7 @@ subprojects {
|
||||
shade "me.hypherionmc.sdlink:mcdiscordformatter-1.20.3:${discord_formatter}"
|
||||
shade "net.kyori:adventure-api:${adventure}"
|
||||
shade "net.kyori:adventure-text-serializer-gson:${adventure}"
|
||||
shade "net.kyori:adventure-text-minimessage:${adventure}"
|
||||
|
||||
compileOnly 'net.luckperms:api:5.4'
|
||||
compileOnly("org.projectlombok:lombok:${lombok}")
|
||||
|
@@ -26,7 +26,7 @@ neoforge_version=0.0-beta
|
||||
# Dependencies
|
||||
moon_config=1.0.9
|
||||
lombok=1.18.32
|
||||
adventure=4.16.0
|
||||
adventure=4.17.0
|
||||
rpc_sdk=1.0
|
||||
discord_formatter=2.0.0
|
||||
|
||||
|
Reference in New Issue
Block a user