Class StringHelper
java.lang.Object
com.pixelmonmod.pixelmon.api.util.helpers.StringHelper
Static helper class for functions in relation to Strings
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringbuildStringForConsecutiveNumbers(List<Integer> listOfNumbers) Builds a string to list consecutive numbers simpler.static StringcapitalizeAllWords(String str) Capitalizes the first letter and every letter that appears after a space.static StringcapitalizeString(String str) static String[]findValuesAfterKeyBeforeSpace(String text, String key) Gets all the text after thekeyand before the next space in thetext.static net.minecraft.network.chat.MutableComponentgetFormattedDuration(long timeMillis) static net.minecraft.network.chat.MutableComponentgetFormattedDuration(long timeMillis, boolean fullOutWritten) static Stringstatic String
-
Constructor Details
-
StringHelper
public StringHelper()
-
-
Method Details
-
findValuesAfterKeyBeforeSpace
Gets all the text after thekeyand before the next space in thetext. Will return null if the key is not found. Ignores any keys found between the end of an initial key and the next space.For example:splitValuesAfterKey("abra move1:mirror_move move2:fly move3", "move")should return ["1:mirror_move", "2:fly", "3"] (and not ["1:mirror_", "2:fly", "3"])splitValuesAfterKey("abra ability:synchronize shiny", "move")would produce an empty String array.- Parameters:
text- The text to search throughkey- The key being searched for- Returns:
- The text after the key before the next space or end of line
-
stripSpecialCharacters
-
toID
-
getFormattedDuration
public static net.minecraft.network.chat.MutableComponent getFormattedDuration(long timeMillis) -
getFormattedDuration
public static net.minecraft.network.chat.MutableComponent getFormattedDuration(long timeMillis, boolean fullOutWritten) -
capitalizeString
-
capitalizeAllWords
Capitalizes the first letter and every letter that appears after a space.- Parameters:
str- the string to have every word capitalized- Returns:
- the given string with the first letter of each word capitalized
-
buildStringForConsecutiveNumbers
Builds a string to list consecutive numbers simpler.Builds a string where a range of consecutive numbers has the inner numbers replaced with a dash and the outer numbers (the min and max of the range) shown. If numbers are not consecutive, they are listed with a comma and space between the next number range.
- Parameters:
listOfNumbers- A List- Returns:
- a string of the format "1-4, 6-7, 9-11, 13"
-