Class SmartString
java.lang.Object
top.magstar.framework.SmartString
Converts custom RGB-style markup into Minecraft-supported formatting codes.
Supported formats:
<#RRGGBB>text</#>— RGB color<bold>text</bold>— Bold<italic>text</italic>— Italic<underlined>text</underlined>— Underlined<strikethrough>text</strikethrough>— Strikethrough<obfuscated>text</obfuscated>— Obfuscated (magic text)<gradient:#RRGGBB:#RRGGBB:#RRGGBB:...>text</gradient>— Gradient between multiple colors
Advanced formats:
<rainbow>text</rainbow>— Rainbow colored text (cannot be nested inside other tags).<progress_bar:{progress}:{length}:{#color1}:{#color2}:...>X</progress_bar>— Progress bar with gradient fill;Xmust be a single character. (cannot be nested inside other tags).<center:{width}>example</center>— Center-align text (nested tags allowed).<click:{action}:{value}>example</click>— Clickable events supporting actions:change_page,copy,command,suggest. (only color tags can be nested, gradient not allowed).<hover:{action}:{content1}:{content2}:...>example</hover>— Hover events supporting actions:text,item. (only color tags can be nested, gradient not allowed).
This system enables combining rich text formatting with interactive features such as hover and click events, while extending Minecraft's default chat formatting codes.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NotNull SmartString@NotNull SmartStringappend(@NotNull SmartString... args) @NotNull SmartStringcenter(int width) 居中显示文本boolean检查是否包含高级标签boolean检查字符串是否包含RGB格式标签int获取不含格式代码的纯文本长度boolean比较两个SmartString的内容是否相等@NotNull String便捷方法:直接获取解析后的字符串@NotNull String@NotNull SmartStringinthashCode()返回字符串的哈希码booleanisEmpty()检查字符串是否为空或仅包含空白字符intlength()获取字符串长度@NotNull SmartString@NotNull SmartString@NotNull SmartStringreplacePlaceholders(@NotNull String... input) @NotNull SmartString移除所有颜色符号与格式标签,只保留纯文本@NotNull SmartStringsubstring(int start, int end) 截取字符串的一部分net.md_5.bungee.api.chat.BaseComponent[]@NotNull ComponentString将SmartString转换为ComponentString,用于高级标签处理@NotNull SmartString转换为小写@NotNull StringtoString()@NotNull SmartString转换为大写
-
Constructor Details
-
SmartString
-
SmartString
public SmartString() -
SmartString
-
-
Method Details
-
getString
-
toString
-
getTranslated
-
removeSpace
-
parseRGBFormat
-
toComponents
public net.md_5.bungee.api.chat.BaseComponent[] toComponents() -
getParsedString
便捷方法:直接获取解析后的字符串 -
containsAdvancedTags
public boolean containsAdvancedTags()检查是否包含高级标签 -
containsRGBFormat
public boolean containsRGBFormat()检查字符串是否包含RGB格式标签 -
stripFormatting
移除所有颜色符号与格式标签,只保留纯文本 -
append
-
append
-
replacePlaceholders
-
isEmpty
public boolean isEmpty()检查字符串是否为空或仅包含空白字符- Returns:
- 如果字符串为空或仅含空白字符返回true
-
length
public int length()获取字符串长度- Returns:
- 字符串长度
-
contentLength
public int contentLength()获取不含格式代码的纯文本长度- Returns:
- 纯文本长度
-
substring
截取字符串的一部分- Parameters:
start- 起始索引end- 结束索引- Returns:
- 新的SmartString对象
-
toLowerCase
-
toUpperCase
-
center
居中显示文本- Parameters:
width- 总宽度- Returns:
- 居中的文本
-
equals
-
hashCode
-
toComponentString
将SmartString转换为ComponentString,用于高级标签处理- Returns:
- 新的ComponentString对象
-
replace
-