package com.Acrobot.Breeze.Utils;

import org.apache.commons.lang.WordUtils;
import org.bukkit.ChatColor;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author Acrobot
 */
public class StringUtil {

    /**
     * Capitalizes every first letter of a word
     *
     * @param string    String to reformat
     * @param separator Word separator
     * @return Reformatted string
     */
    public static String capitalizeFirstLetter(String string, char separator) {
        char[] separators = new char[]{separator};

        return WordUtils.capitalizeFully(string, separators).replace(String.valueOf(separator), " ");
    }

    /**
     * Capitalizes every first letter of a word
     *
     * @param string String to reformat
     * @return Reformatted string
     * @see com.Acrobot.Breeze.Utils.StringUtil#capitalizeFirstLetter(String, char)
     */
    public static String capitalizeFirstLetter(String string) {
        return capitalizeFirstLetter(string, ' ');
    }

    /**
     * Joins a String array
     *
     * @param array array to join
     * @return Joined array
     */
    public static String joinArray(String[] array) {
        return joinArray(Arrays.asList(array));
    }

    /**
     * Joins an iterable
     *
     * @param array Iterable
     * @return Joined iterable
     */
    public static String joinArray(Collection<String> array) {
        return array.stream().collect(Collectors.joining(" "));
    }

    /**
     * Strips colour codes from a string
     * @param string String to strip
     * @return Stripped string
     */
    public static String stripColourCodes(String string) {
        return ChatColor.stripColor(string);
    }

    /**
     * Stips colour codes from an array of strings
     * @param strings Strings to strip the codes from
     * @return Stripped strings
     */
    public static String[] stripColourCodes(String[] strings) {
        List<String> output = new ArrayList<String>();

        for (String string : strings) {
            output.add(stripColourCodes(string));
        }

        return output.toArray(new String[output.size()]);
    }
}

@@ -121,130 +121,18 @@
 til.
-ArrayList;%0Aimport java.util.Arrays;%0Aimport java.util.Collection;%0Aimport java.util.List;%0Aimport java.util.stream.Collectors
+Collection
 ;%0A%0A/
@@ -1148,39 +1148,31 @@
 urn 
-joinArray(Arrays.asList(
+String.join(%22 %22, 
 array)
-)
 ;%0A  
@@ -1366,54 +1366,30 @@
 urn 
-array.stream().collect(Collectors
+String
 .join
-ing
 (%22 %22
-)
+, array
 );%0A 
@@ -1855,28 +1855,24 @@
         
-List%3C
 String
-%3E
+%5B%5D
  output 
@@ -1881,66 +1881,80 @@
 new 
-ArrayList%3CString%3E();%0A%0A        for (String string : strings
+String%5Bstrings.length%5D;%0A%0A        for (int i = 0; i %3C strings.length; i++
 ) %7B%0A
@@ -1975,13 +1975,14 @@
 tput
-.add(
+%5Bi%5D = 
 stri
@@ -2000,17 +2000,20 @@
 s(string
-)
+s%5Bi%5D
 );%0A     
@@ -2043,43 +2043,8 @@
 tput
-.toArray(new String%5Boutput.size()%5D)
 ;%0A  

Optimize StringUtil