Adds ability to append to a format builder
All checks were successful
KnarCraft/KnarLib/pipeline/head This commit looks good
All checks were successful
KnarCraft/KnarLib/pipeline/head This commit looks good
This commit is contained in:
@@ -49,6 +49,7 @@ public final class FormatBuilder {
|
||||
* @param replacements <p>The replacements</p>
|
||||
* @return <p>This format builder</p>
|
||||
*/
|
||||
@NotNull
|
||||
public FormatBuilder replace(@NotNull List<String> placeholders, @NotNull List<String> replacements) {
|
||||
this.toFormat = StringFormatter.replacePlaceholders(this.toFormat, placeholders, replacements);
|
||||
return this;
|
||||
@@ -61,6 +62,7 @@ public final class FormatBuilder {
|
||||
* @param replacement <p>The replacement</p>
|
||||
* @return <p>This format builder</p>
|
||||
*/
|
||||
@NotNull
|
||||
public FormatBuilder replace(@NotNull String placeholder, @NotNull String replacement) {
|
||||
this.toFormat = StringFormatter.replacePlaceholder(this.toFormat, placeholder, replacement);
|
||||
return this;
|
||||
@@ -73,8 +75,9 @@ public final class FormatBuilder {
|
||||
* @param replacement <p>The replacement translatable message</p>
|
||||
* @return <p>This format builder</p>
|
||||
*/
|
||||
@NotNull
|
||||
public FormatBuilder replace(@NotNull String placeholder, @NotNull TranslatableMessage replacement) {
|
||||
this.toFormat = StringFormatter.replacePlaceholder(this.toFormat, placeholder,
|
||||
this.toFormat = StringFormatter.replacePlaceholder(this.toFormat, placeholder,
|
||||
stringFormatter.getUnFormattedMessage(replacement));
|
||||
return this;
|
||||
}
|
||||
@@ -86,6 +89,7 @@ public final class FormatBuilder {
|
||||
* @param replacements <p>The replacements</p>
|
||||
* @return <p>This format builder</p>
|
||||
*/
|
||||
@NotNull
|
||||
public FormatBuilder replace(@NotNull String[] placeholders, @NotNull String[] replacements) {
|
||||
this.toFormat = StringFormatter.replacePlaceholders(this.toFormat, placeholders, replacements);
|
||||
return this;
|
||||
@@ -97,6 +101,7 @@ public final class FormatBuilder {
|
||||
* @param stringReplacer <p>The string replacer used for replacement</p>
|
||||
* @return <p>This format builder</p>
|
||||
*/
|
||||
@NotNull
|
||||
public FormatBuilder replace(@NotNull StringReplacer stringReplacer) {
|
||||
this.toFormat = stringReplacer.replace(this.toFormat);
|
||||
return this;
|
||||
@@ -110,11 +115,36 @@ public final class FormatBuilder {
|
||||
*
|
||||
* @return <p>This format builder</p>
|
||||
*/
|
||||
@NotNull
|
||||
public FormatBuilder color() {
|
||||
this.toFormat = stringFormatter.getUnFormattedColoredMessage(this.toFormat);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the given string to this format builder
|
||||
*
|
||||
* @param input <p>The input to append</p>
|
||||
* @return <p>This format builder</p>
|
||||
*/
|
||||
@NotNull
|
||||
public FormatBuilder append(@NotNull String input) {
|
||||
this.toFormat += input;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends the given translatable message to this format builder
|
||||
*
|
||||
* @param translatableMessage <p>The translatable message to append</p>
|
||||
* @return <p>This format builder</p>
|
||||
*/
|
||||
@NotNull
|
||||
public FormatBuilder append(@NotNull TranslatableMessage translatableMessage) {
|
||||
this.toFormat += stringFormatter.getUnFormattedMessage(translatableMessage);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the output of the performed replacements and formatting
|
||||
*
|
||||
|
Reference in New Issue
Block a user