Class StringUtils

java.lang.Object
me.yleoft.zAPI.utils.StringUtils

public abstract class StringUtils extends Object
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 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 check
      prefix - 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 for
      string - The string to transform
      Returns:
      The transformed string
    • transform

      @NotNull public static @NotNull String 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
    • 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 for
      string - 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 for
      string - The string to apply placeholders to
      Returns:
      The string with placeholders applied
    • color

      @NotNull public static @NotNull String color(@NotNull @NotNull String string)
      Apply color codes to a string.
      Parameters:
      string - The string to apply color codes to
      Returns:
      The string with color codes applied
    • hex

      @NotNull public static @NotNull String hex(@NotNull @NotNull String string)
      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

      public static boolean isInteger(@NotNull @NotNull String strNum)
      Check if a string is an integer.
      Parameters:
      strNum - The string to check
      Returns:
      true if the string is an integer, false otherwise
    • parseAsTime

      public static long parseAsTime(@NotNull @NotNull String time)
      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

      public static String parseAsString(long time)
      Parse milliseconds to time string.
      Parameters:
      time - The time in milliseconds to parse
      Returns:
      The time parsed as time string