Package co.crystaldev.alpinecore.util
Class Formatting
java.lang.Object
co.crystaldev.alpinecore.util.Formatting
Utility for formatting generic strings of text.
- Since:
- 0.1.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull net.kyori.adventure.text.Component
applyTitlePadding
(@NotNull AlpinePlugin plugin, @NotNull net.kyori.adventure.text.Component component) Appends padding around the provided component.static <T> @NotNull net.kyori.adventure.text.Component
elements
(@NotNull AlpinePlugin plugin, @NotNull Collection<T> elements, @NotNull Function<@NotNull T, net.kyori.adventure.text.Component> toComponentFn) Converts a collection of elements into a componentstatic @NotNull String
formatPlaceholders
(@NotNull AlpinePlugin plugin, @Nullable String text, @NotNull Object... placeholders) Deprecated.Renamed.static @NotNull String
formatPlaceholders
(@NotNull AlpinePlugin plugin, @Nullable String text, @NotNull Map<String, Object> placeholders) Deprecated.Renamed.static @NotNull String
formatPlaceholders
(@NotNull net.kyori.adventure.text.minimessage.MiniMessage miniMessage, @Nullable String text, @NotNull Object... placeholders) Deprecated.Renamed.static @NotNull String
formatPlaceholders
(@NotNull net.kyori.adventure.text.minimessage.MiniMessage miniMessage, @Nullable String text, @NotNull Map<String, Object> placeholders) Deprecated.Renamed.static @NotNull String
formatPlaceholders
(@Nullable String text, @NotNull Object... placeholders) Deprecated.Renamed.static @NotNull String
formatPlaceholders
(@Nullable String text, @NotNull Map<String, Object> placeholders) Deprecated.Renamed.static <T> @NotNull net.kyori.adventure.text.Component
page
(@NotNull AlpinePlugin plugin, @NotNull net.kyori.adventure.text.Component title, @NotNull Collection<T> elements, @NotNull String command, int currentPage, int elementsPerPage, @NotNull Function<@NotNull T, net.kyori.adventure.text.Component> toComponentFn) Generates a paginated component display for a collection of elementsstatic @NotNull String
placeholders
(@NotNull AlpinePlugin plugin, @Nullable String text, @NotNull Object... placeholders) Formats text with placeholders.static @NotNull String
placeholders
(@NotNull AlpinePlugin plugin, @Nullable String text, @NotNull Map<String, Object> placeholders) Formats text with placeholders.static @NotNull String
placeholders
(@NotNull net.kyori.adventure.text.minimessage.MiniMessage miniMessage, @Nullable String text, @NotNull Object... placeholders) Formats text with placeholders.static @NotNull String
placeholders
(@NotNull net.kyori.adventure.text.minimessage.MiniMessage miniMessage, @Nullable String text, @NotNull Map<String, Object> placeholders) Formats text with placeholders.static @NotNull String
placeholders
(@Nullable String text, @NotNull Object... placeholders) Formats text with placeholders.static @NotNull String
placeholders
(@Nullable String text, @NotNull Map<String, Object> placeholders) Formats text with placeholders.static @NotNull net.kyori.adventure.text.Component
progress
(@NotNull AlpinePlugin plugin, double progress) Generates a progress bar component based on the specified progress value.static @NotNull net.kyori.adventure.text.Component
title
(@NotNull AlpinePlugin plugin, @NotNull net.kyori.adventure.text.Component component) Formats the given component as a title.
-
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
- TheMiniMessage
instance.text
- The text to formatplaceholders
- 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) Deprecated.Renamed. Useplaceholders(MiniMessage, String, Object...)
-
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 formatplaceholders
- 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) Deprecated.Renamed. Useplaceholders(AlpinePlugin, String, Object...)
-
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 formatplaceholders
- 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.Renamed. Useplaceholders(String, Object...)
- 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
- TheMiniMessage
instance.text
- The text to formatplaceholders
- 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.Renamed. Useplaceholders(MiniMessage, String, Map)
- 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 formatplaceholders
- 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.Renamed. Useplaceholders(AlpinePlugin, String, Map)
- 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 formatplaceholders
- 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.Renamed. Useplaceholders(String, Map)
- 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 plugincomponent
- 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 plugincomponent
- 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 pluginelements
- The elements to be displayedtoComponentFn
- 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 plugintitle
- The title componentelements
- The elements to be paginatedcommand
- The command used to navigate pagescurrentPage
- The current page number (1-indexed)elementsPerPage
- The number of elements to display per pagetoComponentFn
- 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 pluginprogress
- The progress value- Returns:
- The progress bar
-