public class ColorParser
extends java.lang.Object
&+颜色代码
,如 &c 、&a
&(#XXXXXX)
,如 &(#aaaaaa)
&<#XXXXXX>FOOBAR&<#XXXXXX>
注意:当使用渐变RGB颜色时,普通颜色代码与RGB颜色代码将失效。
限定符和类型 | 字段和说明 |
---|---|
static java.util.regex.Pattern |
COLOR_PATTERN |
static java.util.regex.Pattern |
FORMAT_PATTERN |
static java.util.regex.Pattern |
GRADIENT_PATTERN |
static java.util.regex.Pattern |
HEX_PATTERN |
构造器和说明 |
---|
ColorParser() |
限定符和类型 | 方法和说明 |
---|---|
protected static java.lang.String |
buildExtraFormat(java.lang.String current,
java.lang.String extra) |
protected static java.lang.String |
buildHexColor(java.lang.String hexCode) |
static @NotNull java.lang.String |
clear(@NotNull java.lang.String text)
清除一条消息中的全部颜色代码 (包括RGB颜色代码与渐变颜色代码)
|
protected static java.lang.String |
colorToHex(java.awt.Color color) |
protected static java.lang.String |
colorToHex(int r,
int g,
int b) |
static @NotNull java.lang.String |
gradientText(@NotNull java.lang.String text,
@Nullable java.awt.Color startColor,
@Nullable java.awt.Color endColor) |
protected static java.lang.String |
gradientText(@NotNull java.lang.String text,
@Nullable java.lang.String startHex,
@Nullable java.lang.String endHex) |
protected static boolean |
isResetCode(java.lang.String input) |
static @NotNull java.util.List<java.lang.String> |
parse(@NotNull java.util.Collection<java.lang.String> texts)
对多条消息进行颜色解析,包括普通颜色代码、RGB颜色代码与RBG渐变代码。
|
static @NotNull java.lang.String[] |
parse(java.lang.String... texts)
对多条消息进行颜色解析,包括普通颜色代码、RGB颜色代码与RBG渐变代码。
|
static @NotNull java.lang.String |
parse(@NotNull java.lang.String text)
对一条消息进行颜色解析,包括普通颜色代码、RGB颜色代码与RBG渐变代码。
|
static java.lang.String |
parseBaseColor(java.lang.String text)
解析消息中的基本颜色代码格式
&+颜色代码 ,如 &c 、&a |
static @NotNull java.lang.String |
parseGradientColor(@NotNull java.lang.String text)
对一条消息进行RGB渐变处理(版本需要≥1.14),格式
&<#XXXXXX>FOOBAR&<#XXXXXX> 。 |
static java.lang.String |
parseHexColor(java.lang.String text)
解析消息中的RGB颜色代码(版本需要≥1.14) 格式
&(#XXXXXX) ,如 &(#aaaaaa) |
public static final java.util.regex.Pattern HEX_PATTERN
public static final java.util.regex.Pattern GRADIENT_PATTERN
public static final java.util.regex.Pattern COLOR_PATTERN
public static final java.util.regex.Pattern FORMAT_PATTERN
@NotNull public static @NotNull java.lang.String clear(@NotNull @NotNull java.lang.String text)
text
- 源消息内容@NotNull public static @NotNull java.lang.String parse(@NotNull @NotNull java.lang.String text)
text
- 源消息内容@NotNull public static @NotNull java.lang.String[] parse(@NotNull java.lang.String... texts)
texts
- 源消息内容@NotNull public static @NotNull java.util.List<java.lang.String> parse(@NotNull @NotNull java.util.Collection<java.lang.String> texts)
texts
- 源消息内容public static java.lang.String parseBaseColor(java.lang.String text)
&+颜色代码
,如 &c 、&atext
- 消息内容ChatColor
public static java.lang.String parseHexColor(java.lang.String text)
&(#XXXXXX)
,如 &(#aaaaaa)text
- 消息内容@NotNull public static @NotNull java.lang.String parseGradientColor(@NotNull @NotNull java.lang.String text)
&<#XXXXXX>FOOBAR&<#XXXXXX>
。text
- 消息内容@NotNull public static @NotNull java.lang.String gradientText(@NotNull @NotNull java.lang.String text, @Nullable @Nullable java.awt.Color startColor, @Nullable @Nullable java.awt.Color endColor)
protected static java.lang.String gradientText(@NotNull @NotNull java.lang.String text, @Nullable @Nullable java.lang.String startHex, @Nullable @Nullable java.lang.String endHex)
protected static java.lang.String colorToHex(java.awt.Color color)
protected static java.lang.String colorToHex(int r, int g, int b)
protected static java.lang.String buildHexColor(java.lang.String hexCode)
protected static java.lang.String buildExtraFormat(java.lang.String current, java.lang.String extra)
protected static boolean isResetCode(java.lang.String input)
Copyright © 2024. All rights reserved.