Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

get all colors in string spigot

public static List<ChatColor> getColors(String string) {

        List<ChatColor> list = new ArrayList<ChatColor>();
        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;
}
Source by www.spigotmc.org #
 
PREVIOUS NEXT
Tagged: #colors #string #spigot
ADD COMMENT
Topic
Name
5+8 =