Class StringUtil


  • public class StringUtil
    extends java.lang.Object
    A Utilities class to manage strings
    • Constructor Summary

      Constructors 
      Constructor Description
      StringUtil()  
    • Method Summary

      Modifier and Type Method Description
      static java.lang.String addColor​(java.lang.String string)
      Gets a String with & converted to ChatColor#COLOUR_CHAR
      static java.util.List<java.lang.String> addColor​(java.util.List<java.lang.String> strings)
      Add color list.
      static java.lang.String combineArgs​(java.lang.String[] args, int startAt, int endAt, boolean useComma)
      Combine args between startAt and endAt to a single string joined by ' '
      static boolean equalsStrings​(boolean caseSensitive, java.lang.String string, java.lang.String... strings)
      Check if the string is in the list of strings
      static boolean equalsStrings​(java.lang.String string, java.lang.String... strings)
      Equals strings boolean.
      static java.lang.String fixedLengthString​(java.lang.String string, int length)
      Make a string a specific length, filling with white spaces
      static java.lang.String getCenteredMessage​(java.lang.String message)
      Gets centered message.
      static java.lang.String getCenteredMessage​(java.lang.String message, java.lang.String format)
      Gets centered message.
      static FancyMessage getCenteredMessage​(FancyMessage message)
      Gets centered message.
      static FancyMessage getCenteredMessage​(FancyMessage fancyMessage, java.lang.String format)
      Gets centered message.
      static org.bukkit.ChatColor getIndexedColour​(int index)
      Gets indexed colour.
      static org.bukkit.ChatColor getIndexedColour​(int index, java.lang.String colours)
      Gets indexed colour.
      static java.util.List<java.lang.String> getLinesFromString​(java.lang.String line)
      Get a string splitting at '|' to make a List of type String
      static java.lang.String getPropercase​(java.lang.String line)
      Change every individual word in a string to proper case
      static int lineWraps​(java.lang.String message)
      Line wraps int.
      static java.util.Map<java.lang.String,​java.lang.Object> mapFromString​(java.lang.String string)
      Map from string map.
      static java.lang.String rainbowChatColor​(java.lang.String string)
      Get a string with every char having a different color
      static java.lang.String replaceToYAMLFriendlyColors​(java.lang.String string)
      Gets a String with ChatColor#COLOUR_CHAR converted to '&'
      static java.lang.String stringFromMap​(java.util.Map<java.lang.String,​java.lang.Object> map)
      String from map string.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • StringUtil

        public StringUtil()
    • Method Detail

      • addColor

        public static java.lang.String addColor​(java.lang.String string)
        Gets a String with & converted to ChatColor#COLOUR_CHAR
        Parameters:
        string - the string
        Returns:
        string
      • addColor

        public static java.util.List<java.lang.String> addColor​(java.util.List<java.lang.String> strings)
        Add color list.
        Parameters:
        strings - List of Strings
        Returns:
        Get the list of strings with colours added
      • replaceToYAMLFriendlyColors

        public static java.lang.String replaceToYAMLFriendlyColors​(java.lang.String string)
        Gets a String with ChatColor#COLOUR_CHAR converted to '&'
        Parameters:
        string - the string
        Returns:
        string
      • combineArgs

        public static java.lang.String combineArgs​(java.lang.String[] args,
                                                   int startAt,
                                                   int endAt,
                                                   boolean useComma)
        Combine args between startAt and endAt to a single string joined by ' '
        Parameters:
        args - the args
        startAt - the start at
        endAt - the end at
        useComma - the use comma
        Returns:
        string
      • getPropercase

        public static java.lang.String getPropercase​(java.lang.String line)
        Change every individual word in a string to proper case
        Parameters:
        line - the line
        Returns:
        propercase
      • getLinesFromString

        public static java.util.List<java.lang.String> getLinesFromString​(java.lang.String line)
        Get a string splitting at '|' to make a List of type String
        Parameters:
        line - the line
        Returns:
        lines from string
      • rainbowChatColor

        public static java.lang.String rainbowChatColor​(java.lang.String string)
        Get a string with every char having a different color
        Parameters:
        string - the message
        Returns:
        the message with each letter as a different colour
      • getIndexedColour

        public static org.bukkit.ChatColor getIndexedColour​(int index)
        Gets indexed colour.
        Parameters:
        index - the index
        Returns:
        the indexed colour
      • getIndexedColour

        public static org.bukkit.ChatColor getIndexedColour​(int index,
                                                            java.lang.String colours)
        Gets indexed colour.
        Parameters:
        index - the index
        colours - the colours
        Returns:
        the indexed colour
      • fixedLengthString

        public static java.lang.String fixedLengthString​(java.lang.String string,
                                                         int length)
        Make a string a specific length, filling with white spaces
        Parameters:
        string - the string
        length - the length
        Returns:
        the string as the length
      • equalsStrings

        public static boolean equalsStrings​(boolean caseSensitive,
                                            java.lang.String string,
                                            java.lang.String... strings)
        Check if the string is in the list of strings
        Parameters:
        caseSensitive - is it case sensitive
        string - the string to check
        strings - all the possible matches
        Returns:
        if the string matches
      • equalsStrings

        public static boolean equalsStrings​(java.lang.String string,
                                            java.lang.String... strings)
        Equals strings boolean.
        Parameters:
        string - the string
        strings - the strings
        Returns:
        the boolean
      • stringFromMap

        public static java.lang.String stringFromMap​(java.util.Map<java.lang.String,​java.lang.Object> map)
        String from map string.
        Parameters:
        map - the map
        Returns:
        the string
      • mapFromString

        public static java.util.Map<java.lang.String,​java.lang.Object> mapFromString​(java.lang.String string)
        Map from string map.
        Parameters:
        string - the string
        Returns:
        the map
      • getCenteredMessage

        public static FancyMessage getCenteredMessage​(FancyMessage message)
        Gets centered message.
        Parameters:
        message - the message
        Returns:
        the centered message
      • getCenteredMessage

        public static java.lang.String getCenteredMessage​(java.lang.String message)
        Gets centered message.
        Parameters:
        message - the message
        Returns:
        the centered message
      • getCenteredMessage

        public static FancyMessage getCenteredMessage​(FancyMessage fancyMessage,
                                                      java.lang.String format)
        Gets centered message.
        Parameters:
        fancyMessage - the fancy message
        format - the format
        Returns:
        the centered message
      • lineWraps

        public static int lineWraps​(java.lang.String message)
        Line wraps int.
        Parameters:
        message - the message
        Returns:
        the int
      • getCenteredMessage

        public static java.lang.String getCenteredMessage​(java.lang.String message,
                                                          java.lang.String format)
        Gets centered message.
        Parameters:
        message - the message
        format - the format
        Returns:
        the centered message