mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
URL style adjust
This commit is contained in:
parent
db8086d6ad
commit
bc53714ac8
@ -6,6 +6,8 @@ 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.kyori.adventure.text.format.Style;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -107,7 +109,7 @@ public class TextUtils {
|
||||
return LegacyComponentSerializer.legacySection().deserialize(rawString);
|
||||
}
|
||||
|
||||
public static @NotNull TextComponent colorizeText(String rawtext) {
|
||||
public static @NotNull TextComponent colorizeText(@NotNull String rawtext) {
|
||||
if(customLegacySerializer == null) {
|
||||
customLegacySerializer = getSerializer();
|
||||
}
|
||||
@ -117,7 +119,20 @@ public class TextUtils {
|
||||
|
||||
@NotNull
|
||||
private static LegacyComponentSerializer getSerializer() {
|
||||
return LegacyComponentSerializer.builder().hexColors().useUnusualXRepeatedCharacterHexFormat().character('&').hexCharacter('#').extractUrls().build();
|
||||
return LegacyComponentSerializer.builder()
|
||||
.hexColors()
|
||||
.useUnusualXRepeatedCharacterHexFormat()
|
||||
.character('&')
|
||||
.hexCharacter('#')
|
||||
.extractUrls(Style.style()
|
||||
.decorate(getURLStyle())
|
||||
.color(NamedTextColor.DARK_AQUA)
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
public static @NotNull TextDecoration[] getURLStyle() {
|
||||
return new TextDecoration[]{TextDecoration.UNDERLINED};
|
||||
}
|
||||
|
||||
public static @NotNull String sanitizeForSerializer(@NotNull String string) {
|
||||
|
Loading…
Reference in New Issue
Block a user