Package me.bimmr.bimmcore.utils
Class StringUtil
- java.lang.Object
-
- me.bimmr.bimmcore.utils.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_CHARstatic 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 stringsstatic 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 spacesstatic 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 Stringstatic java.lang.String
getPropercase(java.lang.String line)
Change every individual word in a string to proper casestatic 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 colorstatic 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.
-
-
-
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 argsstartAt
- the start atendAt
- the end atuseComma
- 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 indexcolours
- 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 stringlength
- 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 sensitivestring
- the string to checkstrings
- 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 stringstrings
- 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 messageformat
- 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 messageformat
- the format- Returns:
- the centered message
-
-