Package me.yleoft.zAPI.util
Class TextFormatter
java.lang.Object
me.yleoft.zAPI.util.TextFormatter
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic net.kyori.adventure.text.ComponentapplyMiniPlaceholders(@Nullable org.bukkit.OfflinePlayer p, @NotNull String string) Apply placeholders to a string for a specific player and turns it into a Component.static @NotNull StringapplyPlaceholders(@Nullable org.bukkit.OfflinePlayer p, @NotNull String string) Apply placeholders to a string for a specific player.static booleanCheck if a string is an integer.static StringparseAsString(long ms) Parse milliseconds to time string.static longparseAsTime(String time) Parse a string as a time in milliseconds.static booleanstartsWithIgnoreCase(@NotNull String full, @NotNull String prefix) Check if a string starts with a given prefix, ignoring case.static @NotNull net.kyori.adventure.text.ComponentTransform a string by applying color codes and hex codes.static @NotNull net.kyori.adventure.text.Componenttransform(@NotNull net.kyori.adventure.text.Component component) Transform a string by applying color codes and hex codes.static @NotNull net.kyori.adventure.text.ComponentTransform a string by applying color codes, hex codes and placeholders and turns it into a Component.static @NotNull net.kyori.adventure.text.Componenttransform(@Nullable org.bukkit.OfflinePlayer p, @NotNull net.kyori.adventure.text.Component component) Transform a string by applying color codes, hex codes and placeholders.static @NotNull StringtransformString(@NotNull String string) Transform a string by applying color codes and hex codes.static @NotNull StringtransformString(@NotNull net.kyori.adventure.text.Component component) Transform a string by applying color codes and hex codes.static @NotNull StringtransformString(@Nullable org.bukkit.OfflinePlayer p, @NotNull String string) Transform a string by applying color codes, hex codes and placeholders.static @NotNull StringtransformString(@Nullable org.bukkit.OfflinePlayer p, @NotNull net.kyori.adventure.text.Component component) Transform a string by applying color codes, hex codes and placeholders.
-
Constructor Details
-
TextFormatter
public TextFormatter()
-
-
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 net.kyori.adventure.text.Component transform(@Nullable @Nullable org.bukkit.OfflinePlayer p, @NotNull @NotNull String string) Transform a string by applying color codes, hex codes and placeholders and turns it into a Component.- Parameters:
p- The player to apply placeholders forstring- The string to transform- Returns:
- The transformed component
-
transformString
@NotNull public static @NotNull String transformString(@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
@NotNull public static @NotNull net.kyori.adventure.text.Component transform(@Nullable @Nullable org.bukkit.OfflinePlayer p, @NotNull @NotNull net.kyori.adventure.text.Component component) Transform a string by applying color codes, hex codes and placeholders.- Parameters:
p- The player to apply placeholders forcomponent- The component to transform- Returns:
- The transformed component
-
transformString
@NotNull public static @NotNull String transformString(@Nullable @Nullable org.bukkit.OfflinePlayer p, @NotNull @NotNull net.kyori.adventure.text.Component component) Transform a string by applying color codes, hex codes and placeholders.- Parameters:
p- The player to apply placeholders forcomponent- The component to transform- Returns:
- The transformed string
-
transform
@NotNull public static @NotNull net.kyori.adventure.text.Component transform(@NotNull @NotNull String string) Transform a string by applying color codes and hex codes.- Parameters:
string- The string to transform- Returns:
- The transformed string
-
transformString
Transform a string by applying color codes and hex codes.- Parameters:
string- The string to transform- Returns:
- The transformed string
-
transform
@NotNull public static @NotNull net.kyori.adventure.text.Component transform(@NotNull @NotNull net.kyori.adventure.text.Component component) Transform a string by applying color codes and hex codes.- Parameters:
component- The component to transform- Returns:
- The transformed string
-
transformString
@NotNull public static @NotNull String transformString(@NotNull @NotNull net.kyori.adventure.text.Component component) Transform a string by applying color codes and hex codes.- Parameters:
component- The component 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
-
applyMiniPlaceholders
public static net.kyori.adventure.text.Component applyMiniPlaceholders(@Nullable @Nullable org.bukkit.OfflinePlayer p, @NotNull @NotNull String string) Apply placeholders to a string for a specific player and turns it into a Component.- Parameters:
p- The player to apply placeholders forstring- The string to apply placeholders to- Returns:
- The component with placeholders 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:
ms- The time in milliseconds to parse- Returns:
- The time parsed as time string
-