Class TextFormatter

java.lang.Object
me.yleoft.zAPI.util.TextFormatter

public abstract class TextFormatter extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static net.kyori.adventure.text.Component
    applyMiniPlaceholders(@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 String
    applyPlaceholders(@Nullable org.bukkit.OfflinePlayer p, @NotNull String string)
    Apply placeholders to a string for a specific player.
    static boolean
    isInteger(@NotNull String strNum)
    Check if a string is an integer.
    static String
    parseAsString(long ms)
    Parse milliseconds to time string.
    static long
    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 net.kyori.adventure.text.Component
    transform(@NotNull String string)
    Transform a string by applying color codes and hex codes.
    static @NotNull net.kyori.adventure.text.Component
    transform(@NotNull net.kyori.adventure.text.Component component)
    Transform a string by applying color codes and hex codes.
    static @NotNull net.kyori.adventure.text.Component
    transform(@Nullable org.bukkit.OfflinePlayer p, @NotNull String string)
    Transform a string by applying color codes, hex codes and placeholders and turns it into a Component.
    static @NotNull net.kyori.adventure.text.Component
    transform(@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 String
    transformString(@NotNull String string)
    Transform a string by applying color codes and hex codes.
    static @NotNull String
    transformString(@NotNull net.kyori.adventure.text.Component component)
    Transform a string by applying color codes and hex codes.
    static @NotNull String
    transformString(@Nullable org.bukkit.OfflinePlayer p, @NotNull String string)
    Transform a string by applying color codes, hex codes and placeholders.
    static @NotNull String
    transformString(@Nullable org.bukkit.OfflinePlayer p, @NotNull net.kyori.adventure.text.Component component)
    Transform a string by applying color codes, hex codes and placeholders.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 check
      prefix - 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 for
      string - 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 for
      string - 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 for
      component - 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 for
      component - 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

      @NotNull public static @NotNull String transformString(@NotNull @NotNull String string)
      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 for
      string - 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 for
      string - The string to apply placeholders to
      Returns:
      The component with placeholders 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(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 ms)
      Parse milliseconds to time string.
      Parameters:
      ms - The time in milliseconds to parse
      Returns:
      The time parsed as time string