Class Formatting

java.lang.Object
co.crystaldev.alpinecore.util.Formatting

public final class Formatting extends Object
Utility for formatting generic strings of text.
Since:
0.1.0
  • Constructor Details

    • Formatting

      public Formatting()
  • Method Details

    • placeholders

      @NotNull public static @NotNull String placeholders(@NotNull @NotNull net.kyori.adventure.text.minimessage.MiniMessage miniMessage, @Nullable @Nullable String text, @NotNull @NotNull Object... placeholders)
      Formats text with placeholders.

      Placeholders are denoted with percent symbols on either side.

      Parameters:
      miniMessage - The MiniMessage instance.
      text - The text to format
      placeholders - The placeholders used to format the text
      Returns:
      The formatted text
    • formatPlaceholders

      @NotNull @Deprecated public static @NotNull String formatPlaceholders(@NotNull @NotNull net.kyori.adventure.text.minimessage.MiniMessage miniMessage, @Nullable @Nullable String text, @NotNull @NotNull Object... placeholders)
    • placeholders

      @NotNull public static @NotNull String placeholders(@NotNull @NotNull AlpinePlugin plugin, @Nullable @Nullable String text, @NotNull @NotNull Object... placeholders)
      Formats text with placeholders.

      Placeholders are denoted with percent symbols on either side.

      Parameters:
      plugin - The owning plugin.
      text - The text to format
      placeholders - The placeholders used to format the text
      Returns:
      The formatted text
    • formatPlaceholders

      @NotNull @Deprecated public static @NotNull String formatPlaceholders(@NotNull @NotNull AlpinePlugin plugin, @Nullable @Nullable String text, @NotNull @NotNull Object... placeholders)
      See Also:
    • placeholders

      @NotNull public static @NotNull String placeholders(@Nullable @Nullable String text, @NotNull @NotNull Object... placeholders)
      Formats text with placeholders.

      Placeholders are denoted with percent symbols on either side.

      Parameters:
      text - The text to format
      placeholders - The placeholders used to format the text
      Returns:
      The formatted text
    • formatPlaceholders

      @NotNull @Deprecated public static @NotNull String formatPlaceholders(@Nullable @Nullable String text, @NotNull @NotNull Object... placeholders)
      Deprecated.
      See Also:
    • placeholders

      @NotNull public static @NotNull String placeholders(@NotNull @NotNull net.kyori.adventure.text.minimessage.MiniMessage miniMessage, @Nullable @Nullable String text, @NotNull @NotNull Map<String,Object> placeholders)
      Formats text with placeholders.

      Placeholders are denoted with percent symbols on either side.

      Parameters:
      miniMessage - The MiniMessage instance.
      text - The text to format
      placeholders - The placeholders used to format the text
      Returns:
      The formatted text
    • formatPlaceholders

      @NotNull @Deprecated public static @NotNull String formatPlaceholders(@NotNull @NotNull net.kyori.adventure.text.minimessage.MiniMessage miniMessage, @Nullable @Nullable String text, @NotNull @NotNull Map<String,Object> placeholders)
      Deprecated.
      See Also:
    • placeholders

      @NotNull public static @NotNull String placeholders(@NotNull @NotNull AlpinePlugin plugin, @Nullable @Nullable String text, @NotNull @NotNull Map<String,Object> placeholders)
      Formats text with placeholders.

      Placeholders are denoted with percent symbols on either side.

      Parameters:
      plugin - The owning plugin.
      text - The text to format
      placeholders - The placeholders used to format the text
      Returns:
      The formatted text
    • formatPlaceholders

      @NotNull @Deprecated public static @NotNull String formatPlaceholders(@NotNull @NotNull AlpinePlugin plugin, @Nullable @Nullable String text, @NotNull @NotNull Map<String,Object> placeholders)
      Deprecated.
      See Also:
    • placeholders

      @NotNull public static @NotNull String placeholders(@Nullable @Nullable String text, @NotNull @NotNull Map<String,Object> placeholders)
      Formats text with placeholders.

      Placeholders are denoted with percent symbols on either side.

      Parameters:
      text - The text to format
      placeholders - The placeholders used to format the text
      Returns:
      The formatted text
    • formatPlaceholders

      @NotNull @Deprecated public static @NotNull String formatPlaceholders(@Nullable @Nullable String text, @NotNull @NotNull Map<String,Object> placeholders)
      Deprecated.
      See Also:
    • applyTitlePadding

      @NotNull public static @NotNull net.kyori.adventure.text.Component applyTitlePadding(@NotNull @NotNull AlpinePlugin plugin, @NotNull @NotNull net.kyori.adventure.text.Component component)
      Appends padding around the provided component.
      Parameters:
      plugin - The owning plugin
      component - The component
      Returns:
      The padded component
    • title

      @NotNull public static @NotNull net.kyori.adventure.text.Component title(@NotNull @NotNull AlpinePlugin plugin, @NotNull @NotNull net.kyori.adventure.text.Component component)
      Formats the given component as a title.
      This includes applying title formatting and optionally adding padding around the title.
      Parameters:
      plugin - The owning plugin
      component - The component
      Returns:
      The formatted title component
    • elements

      @NotNull public static <T> @NotNull net.kyori.adventure.text.Component elements(@NotNull @NotNull AlpinePlugin plugin, @NotNull @NotNull Collection<T> elements, @NotNull @NotNull Function<@NotNull T,net.kyori.adventure.text.Component> toComponentFn)
      Converts a collection of elements into a component
      Parameters:
      plugin - The owning plugin
      elements - The elements to be displayed
      toComponentFn - The function to convert each element into a component
      Returns:
      The displayed components
    • page

      @NotNull public static <T> @NotNull net.kyori.adventure.text.Component page(@NotNull @NotNull AlpinePlugin plugin, @NotNull @NotNull net.kyori.adventure.text.Component title, @NotNull @NotNull Collection<T> elements, @NotNull @NotNull String command, int currentPage, int elementsPerPage, @NotNull @NotNull Function<@NotNull T,net.kyori.adventure.text.Component> toComponentFn)
      Generates a paginated component display for a collection of elements
      Parameters:
      plugin - The owning plugin
      title - The title component
      elements - The elements to be paginated
      command - The command used to navigate pages
      currentPage - The current page number (1-indexed)
      elementsPerPage - The number of elements to display per page
      toComponentFn - The function to convert each element into a component
      Returns:
      The paginated components
    • progress

      @NotNull public static @NotNull net.kyori.adventure.text.Component progress(@NotNull @NotNull AlpinePlugin plugin, double progress)
      Generates a progress bar component based on the specified progress value.
      Parameters:
      plugin - The owning plugin
      progress - The progress value
      Returns:
      The progress bar