📜  获取字符串 spigot 中的所有颜色 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:12.692000             🧑  作者: Mango

代码示例1
public static List getColors(String string) {

        List list = new ArrayList();
        String colorCoded =  string.replace(ChatColor.COLOR_CHAR, '&');

        for(int i = 0 ; i < colorCoded.length() ; i++) {
            char c = colorCoded.charAt(i);
            if(c =='&') {
                char id = colorCoded.charAt(i+1);
                list.add(ChatColor.getByChar(id));
            }
        }
        return list;
}