Class ComponentString
java.lang.Object
top.magstar.framework.ComponentString
Represents an advanced text component builder for Minecraft chat messages.
ComponentString allows developers to construct rich chat messages
using an extended placeholder/tag system, which is then parsed into
BungeeCord's BaseComponent array.
Supported Features
- Color and Formatting: Standard § color codes, hex colors, and style modifiers.
- <rainbow>...</rainbow>: Apply rainbow-colored gradient to enclosed text.
- <progress_bar:progress:length:colors>char</progress_bar>: Generate a gradient progress bar.
- <center:width>...</center>: Center-align the content within a given width.
- <linkify:url>...</linkify>: Create clickable hyperlinks with hover hints.
- <hover:action:value>...</hover>: Assign hover text or item tooltips.
- <click:action:value>...</click>: Attach click actions such as running/suggesting commands, copying text, or changing pages.
The class also provides helper builder methods (e.g. withHoverText,
withClickCommand, progressBar) that wrap content with
the corresponding tags, simplifying construction of formatted messages.
- Version:
- 1.0
- Author:
- Magstar
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NotNull ComponentStringcenter(int width) 使内容居中显示@NotNull String获取字符串内容@NotNull ComponentString添加链接static @NotNull ComponentStringprogressBar(double progress, int length, char barChar, String... colors) 创建进度条@NotNull ComponentStringrainbow()应用彩虹效果@NotNull net.md_5.bungee.api.chat.BaseComponent[]解析高级标签并返回BaseComponent数组@NotNull ComponentStringwithChangePage(int page) 添加点击更改页面@NotNull ComponentStringwithClickCommand(@NotNull String command) 添加点击执行命令@NotNull ComponentStringwithCopyText(@NotNull String text) 添加点击复制文本@NotNull ComponentStringwithHoverItem(@NotNull String itemJson) 添加物品悬停提示@NotNull ComponentStringwithHoverText(@NotNull String text) 添加悬停文本@NotNull ComponentStringwithSuggestCommand(@NotNull String command) 添加点击建议命令
-
Constructor Details
-
ComponentString
创建一个新的ComponentString- Parameters:
content- 内容字符串
-
-
Method Details
-
getContent
-
toComponents
@NotNull public @NotNull net.md_5.bungee.api.chat.BaseComponent[] toComponents()解析高级标签并返回BaseComponent数组- Returns:
- 解析后的BaseComponent数组
-
withHoverText
添加悬停文本 -
withHoverItem
添加物品悬停提示 -
withClickCommand
添加点击执行命令 -
withSuggestCommand
添加点击建议命令 -
withCopyText
添加点击复制文本 -
withChangePage
添加点击更改页面 -
center
使内容居中显示 -
linkify
添加链接 -
rainbow
应用彩虹效果 -
progressBar
@NotNull public static @NotNull ComponentString progressBar(double progress, int length, char barChar, String... colors) 创建进度条- Parameters:
progress- 进度 (0.0-1.0)length- 长度barChar- 进度条字符colors- 颜色列表 (十六进制,不含#),最后一个颜色用于未完成部分- Returns:
- 格式化的进度条
-