Makes the format builder accept anything when creating a new format builder

This commit is contained in:
2025-09-13 16:09:38 +02:00
parent 50b515af1d
commit 28510fb0a3

View File

@@ -32,32 +32,24 @@ public final class FormatBuilder {
/** /**
* Instantiates a new format builder * Instantiates a new format builder
* *
* @param stringBuilder <p>The string builder to use output from</p> * <p>If the input is a list, it will be joined using the default delimiter: ",".</p>
*
* @param input <p>The input to use as the initial string of this format builder</p>
* @throws IllegalStateException <p>If the string formatter has not been set, and the input is a translatable message</p>
*/ */
public FormatBuilder(@NotNull StringBuilder stringBuilder) { public <K> FormatBuilder(@NotNull K input) throws IllegalStateException {
this.toFormat = stringBuilder.toString(); this.toFormat = asString(input, LIST_DELIMITER);
} }
/** /**
* Instantiates a new format builder * Instantiates a new format builder
* *
* @param translatableMessage <p>The translatable message to format</p> * @param input <p>The input to use as the initial string of this format builder</p>
* @throws IllegalStateException <p>If the string formatter has not been set</p> * @param delimiter <p>The delimiter used for joining if the input is some kind of list</p>
* @throws IllegalStateException <p>If the string formatter has not been set, and the input is a translatable message</p>
*/ */
public FormatBuilder(@NotNull TranslatableMessage translatableMessage) throws IllegalStateException { public <K> FormatBuilder(@NotNull K input, @NotNull String delimiter) throws IllegalStateException {
if (FormatBuilder.stringFormatter == null) { this.toFormat = asString(input, delimiter);
throw NOT_SETUP_EXCEPTION;
}
this.toFormat = FormatBuilder.stringFormatter.getUnFormattedMessage(translatableMessage);
}
/**
* Instantiates a new format builder
*
* @param toFormat <p>The string to format</p>
*/
public FormatBuilder(@NotNull String toFormat) {
this.toFormat = toFormat;
} }
/** /**