Package me.yleoft.zAPI.utils
Class StringUtils
java.lang.Object
me.yleoft.zAPI.utils.StringUtils
Utility class for string operations, including color and placeholder handling.
This class provides methods to transform strings by applying color codes, hex codes, and placeholders.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull String
applyOwnPlaceholders
(@Nullable org.bukkit.OfflinePlayer p, @NotNull String string) Apply placeholders to a string for a specific player using your own placeholder expansion.static @NotNull String
applyPlaceholders
(@Nullable org.bukkit.OfflinePlayer p, @NotNull String string) Apply placeholders to a string for a specific player.static @NotNull String
Apply color codes to a string.static @NotNull String
Apply hex color codes to a string.static boolean
Check if a string is an integer.static String
parseAsString
(long time) Parse milliseconds to time string.static long
parseAsTime
(@NotNull String time) Parse a string as a time in milliseconds.static boolean
startsWithIgnoreCase
(@NotNull String full, @NotNull String prefix) Check if a string starts with a given prefix, ignoring case.static @NotNull String
Transform a string by applying color codes and hex codes.static @NotNull String
Transform a string by applying color codes, hex codes and placeholders.
-
Constructor Details
-
StringUtils
public StringUtils()
-
-
Method Details
-
startsWithIgnoreCase
public static boolean startsWithIgnoreCase(@NotNull @NotNull String full, @NotNull @NotNull String prefix) Check if a string starts with a given prefix, ignoring case.- Parameters:
full
- The full string to checkprefix
- The prefix to check against- Returns:
- true if the full string starts with the prefix, false otherwise
-
transform
@NotNull public static @NotNull String transform(@Nullable @Nullable org.bukkit.OfflinePlayer p, @NotNull @NotNull String string) Transform a string by applying color codes, hex codes and placeholders.- Parameters:
p
- The player to apply placeholders forstring
- The string to transform- Returns:
- The transformed string
-
transform
Transform a string by applying color codes and hex codes.- Parameters:
string
- The string to transform- Returns:
- The transformed string
-
applyPlaceholders
@NotNull public static @NotNull String applyPlaceholders(@Nullable @Nullable org.bukkit.OfflinePlayer p, @NotNull @NotNull String string) Apply placeholders to a string for a specific player.- Parameters:
p
- The player to apply placeholders forstring
- The string to apply placeholders to- Returns:
- The string with placeholders applied
-
applyOwnPlaceholders
@NotNull public static @NotNull String applyOwnPlaceholders(@Nullable @Nullable org.bukkit.OfflinePlayer p, @NotNull @NotNull String string) Apply placeholders to a string for a specific player using your own placeholder expansion.- Parameters:
p
- The player to apply placeholders forstring
- The string to apply placeholders to- Returns:
- The string with placeholders applied
-
color
Apply color codes to a string.- Parameters:
string
- The string to apply color codes to- Returns:
- The string with color codes applied
-
hex
Apply hex color codes to a string.- Parameters:
string
- The string to apply hex color codes to- Returns:
- The string with hex color codes applied
-
isInteger
Check if a string is an integer.- Parameters:
strNum
- The string to check- Returns:
- true if the string is an integer, false otherwise
-
parseAsTime
Parse a string as a time in milliseconds. The string can be in the format "1h", "30m", "15s", etc.- Parameters:
time
- The time string to parse- Returns:
- The time in milliseconds, or 0 if the string is empty
-
parseAsString
Parse milliseconds to time string.- Parameters:
time
- The time in milliseconds to parse- Returns:
- The time parsed as time string
-