mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-06-28 19:54:44 +02:00
Fix Hex-Colored names in parties/admin chat
This commit is contained in:
@ -1,10 +1,12 @@
|
||||
package com.gmail.nossr50.util.text;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.ComponentBuilder;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -84,4 +86,16 @@ public class TextUtils {
|
||||
static void addNewHoverComponentToTextComponent(@NotNull TextComponent.Builder textComponent, @NotNull Component baseComponent) {
|
||||
textComponent.hoverEvent(HoverEvent.showText(baseComponent));
|
||||
}
|
||||
|
||||
public static BaseComponent[] convertToBungeeComponent(@NotNull String displayName) {
|
||||
return net.md_5.bungee.api.chat.TextComponent.fromLegacyText(displayName);
|
||||
}
|
||||
|
||||
public static @NotNull TextComponent ofBungeeComponents(@NotNull BaseComponent[] bungeeName) {
|
||||
return TextComponent.ofChildren(mcMMO.getCompatibilityManager().getBungeeSerializerCompatibilityLayer().deserialize(bungeeName));
|
||||
}
|
||||
|
||||
public static @NotNull TextComponent ofBungeeRawStrings(@NotNull String bungeeRawString) {
|
||||
return ofBungeeComponents(convertToBungeeComponent(bungeeRawString));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user