Fix Hex-Colored names in parties/admin chat

This commit is contained in:
nossr50
2020-11-06 14:01:07 -08:00
parent b2cdffe965
commit a4fd632d53
23 changed files with 300 additions and 220 deletions

View File

@ -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));
}
}