Allows the format builder to be extended
All checks were successful
KnarCraft/KnarLib/pipeline/head This commit looks good

This commit is contained in:
2025-09-13 16:48:28 +02:00
parent 16bd04f865
commit f3c010934b

View File

@@ -15,13 +15,13 @@ import java.util.List;
* A builder for making a replaced and formatted string * A builder for making a replaced and formatted string
*/ */
@SuppressWarnings("unused") @SuppressWarnings("unused")
public final class FormatBuilder { public class FormatBuilder {
private static @Nullable StringFormatter stringFormatter = null; private static @Nullable StringFormatter stringFormatter = null;
private static final IllegalStateException NOT_SETUP_EXCEPTION = new IllegalStateException("String formatter has not been set!"); private static final IllegalStateException NOT_SETUP_EXCEPTION = new IllegalStateException("String formatter has not been set!");
private static final String LIST_DELIMITER = ","; private static final String LIST_DELIMITER = ",";
private StringBuilder stringBuilder = null; protected StringBuilder stringBuilder = null;
private @NotNull String stringToFormat; protected @NotNull String stringToFormat;
/** /**
* Instantiates a new format builder * Instantiates a new format builder
@@ -247,7 +247,7 @@ public final class FormatBuilder {
* *
* @return <p>The current string</p> * @return <p>The current string</p>
*/ */
private String getCurrentString() { protected String getCurrentString() {
if (this.stringBuilder != null) { if (this.stringBuilder != null) {
this.stringToFormat += this.stringBuilder.toString(); this.stringToFormat += this.stringBuilder.toString();
this.stringBuilder = null; this.stringBuilder = null;
@@ -264,7 +264,7 @@ public final class FormatBuilder {
* @throws IllegalStateException <p>If the string formatter has not been set, and the input is a translatable message.</p> * @throws IllegalStateException <p>If the string formatter has not been set, and the input is a translatable message.</p>
*/ */
@NotNull @NotNull
private <K> String asString(@NotNull K input, @NotNull String delimiter) { protected <K> String asString(@NotNull K input, @NotNull String delimiter) {
if (input instanceof String string) { if (input instanceof String string) {
return string; return string;
} else if (input instanceof TranslatableMessage translatableMessage) { } else if (input instanceof TranslatableMessage translatableMessage) {