Skip to content

Utility Classes

Bogdan T edited this page Jan 30, 2024 · 2 revisions

The Most Useful

Here you will find the description of the most commonly used utility classes, that might greatly help you

String Utils

StringUtils can help you to format the text, and replace() faster than using a default java method.

Major Methods:

 * Format a string with color codes.
 *
 * @param text The text to format.
 * @return The formatted string.
 *
 String format(@NotNull String text)   // This method is overloaded. You can use List as the parameter as well

 * Format a string with color codes and placeholders.
 *
 * @param atumMod The mod.
 * @param text The text to format.
 * @param context The placeholder context.
 * @return The formatted string.
 *
 String formatWithPlaceholders(@NotNull AtumMod atumMod,
                               @NotNull String text,
                               @NotNull PlaceholderContext context) // This method is overloaded. You can use List as the parameter as well


 * Fast implementation of {@link String#replace(CharSequence, CharSequence)}
 *
 * @param input       The input string.
 * @param target      The target string.
 * @param replacement The replacement string.
 * @return The replaced string.
 *
 String replaceFast(@NotNull final String input,
                    @NotNull final String target,
                    @NotNull final String replacement)


 * Remove color codes from a string.
 *
 * @param input The input string.
 * @return The string without color codes.
 *
 String removeColorCodes(String input)

Math Utils

MathUtils Pretty useful, if you use trigonometry, especially in animations

Major Methods:

 * Get sin from lookup table
 * it is significantly faster that Math#sin()
 *
 * @param radians the radians
 * @return result
 *
 double fastSin(final double radians)


 * Get cos from lookup table
 * it is significantly faster that Math#cos()
 *
 * @param radians the radians
 * @return result
 *
 double fastCos(final double radians)

Number Utils

NumberUtils Helps to format the numbers, work with numerals and check the number type.

Major Methods:

 * Format double to string with 2 decimal places.
 *
 * @param toFormat The number to format.
 * @return Formatted.
 *
 String format(final double toFormat)


 * Get Roman Numeral from number.
 *
 * @param number The number to convert.
 * @return The number, converted to a roman numeral.
 *
 String toNumeral(final int number)

 * Get number from roman numeral.
 *
 * @param numeral The numeral to convert.
 * @return The number, converted from a roman numeral.
 *
 int fromNumeral(@NotNull final String numeral)

Clone this wiki locally