Class Txt
java.lang.Object
com.kamikazejam.kamicommon.util.Txt
Static text helpers used throughout the command framework: joining collections, splitting camel case,
prefix filtering for tab completion, turning enum constants into display names, and building the centred
"titleized" lines that head command output. The width, padding character and colours of a titleized line
come from
Txt.Config, which a plugin may change at startup to restyle every such line.-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull StringcamelSplit(String string) static <T> @NotNull List<T> getFiltered(@NotNull Iterable<T> elements, @NotNull Predicate<T> predicate) static <T> @NotNull List<T> getFiltered(T @NotNull [] elements, @NotNull Predicate<T> predicate) static @NotNull VersionedComponentgetItemName(@Nullable ItemStack itemStack) Determines the correct visible name of an item, based on its data (custom name and enchantment glint).
Uses a default name of "Nothing" if the item is null or empty.
See alsogetItemName(ItemStack, VersionedComponent)for supplying your own default name.static @NotNull VersionedComponentgetItemName(@Nullable ItemStack itemStack, @NotNull VersionedComponent defaultName) Determines the correct visible name of an item, based on its data (custom name and enchantment glint).
Uses the supplied if the item is null or empty.static @NotNull StringgetMaterialName(@NotNull Material material) getNicedEnum(T enumObject) getNicedEnum(T enumObject, String glue) static @NotNull StringgetNicedEnumString(@NotNull String str) static @NotNull StringgetNicedEnumString(@NotNull String str, String glue) getStartsWithIgnoreCase(@NotNull Iterable<String> elements, String prefix) getStartsWithIgnoreCase(String @NotNull [] elements, String prefix) static @NotNull Stringstatic @NotNull Stringstatic @NotNull Stringimplode(@NotNull Collection<?> coll, String glue) static @NotNull Stringimplode(@NotNull Collection<?> coll, String glue, @Nullable String format) static @NotNull StringimplodeCommaAndDot(@NotNull Collection<?> objects, @Nullable String format, String comma, String and, String dot) static booleanstatic StringlowerCaseFirst(String string) static StringremoveSmartQuotes(String string) static @NotNull VersionedComponentFormats a given title to be centered in a titleized line.
Titleized lines can be configured inTxt.Config
They feature the centered in additional 'titleized' line characters.static @NotNull VersionedComponenttitleizedPageTitle(@NotNull String title, int pageNum, int pageCount) Forms a page title using , and , and then passes it totitleize(String).
Default format is configured inTxt.Config.pageTitleFormatMiniand looks like:tokenizeArguments(@NotNull String str) static StringupperCaseFirst(String string)
-
Field Details
-
PATTERN_WHITESPACE
-
PATTERN_NEWLINE
-
millisPerSecond
public static final long millisPerSecond- See Also:
-
millisPerMinute
public static final long millisPerMinute- See Also:
-
millisPerHour
public static final long millisPerHour- See Also:
-
millisPerDay
public static final long millisPerDay- See Also:
-
millisPerWeek
public static final long millisPerWeek- See Also:
-
millisPerMonth
public static final long millisPerMonth- See Also:
-
millisPerYear
public static final long millisPerYear- See Also:
-
vowel
-
PATTERN_ENUM_SPLIT
-
-
Constructor Details
-
Txt
public Txt()
-
-
Method Details
-
upperCaseFirst
-
lowerCaseFirst
-
isVowel
-
aan
-
implode
-
implode
-
implode
@NotNull public static @NotNull String implode(@NotNull @NotNull Collection<?> coll, String glue, @Nullable @Nullable String format) -
implode
-
implodeCommaAndDot
-
camelSplit
-
getFiltered
-
getFiltered
-
getStartsWithIgnoreCase
-
getStartsWithIgnoreCase
-
getNicedEnumString
-
getNicedEnumString
-
getNicedEnum
-
getNicedEnum
-
getMaterialName
-
getItemName
@NotNull public static @NotNull VersionedComponent getItemName(@Nullable @Nullable ItemStack itemStack) Determines the correct visible name of an item, based on its data (custom name and enchantment glint).
Uses a default name of "Nothing" if the item is null or empty.
See alsogetItemName(ItemStack, VersionedComponent)for supplying your own default name.- Returns:
- The name of the item, or a default name if the item is null or empty.
-
getItemName
@NotNull public static @NotNull VersionedComponent getItemName(@Nullable @Nullable ItemStack itemStack, @NotNull @NotNull VersionedComponent defaultName) Determines the correct visible name of an item, based on its data (custom name and enchantment glint).
Uses the supplied if the item is null or empty.- Returns:
- The name of the item, or the supplied default name if the item is null or empty.
-
tokenizeArguments
-
removeSmartQuotes
-
titleize
Formats a given title to be centered in a titleized line.
Titleized lines can be configured inTxt.Config
They feature the centered in additional 'titleized' line characters.- Parameters:
titleMini- The unformatted title, which will be titleized (still in MiniMessage format).- Returns:
- The titleized page title as a
VersionedComponent.
-
titleizedPageTitle
@NotNull public static @NotNull VersionedComponent titleizedPageTitle(@NotNull @NotNull String title, int pageNum, int pageCount) Forms a page title using , and , and then passes it totitleize(String).
Default format is configured inTxt.Config.pageTitleFormatMiniand looks like:- Parameters:
title- The unformatted title, which will be titleized.pageNum- The current page number, 1-based (e.g. 1 for the first page).pageCount- The total number of pages.- Returns:
- The titleized page title String.
-