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>
|
* @param replacements <p>The replacements</p>
|
||||||
* @return <p>This format builder</p>
|
* @return <p>This format builder</p>
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public FormatBuilder replace(@NotNull List<String> placeholders, @NotNull List<String> replacements) {
|
public FormatBuilder replace(@NotNull List<String> placeholders, @NotNull List<String> replacements) {
|
||||||
this.toFormat = StringFormatter.replacePlaceholders(this.toFormat, placeholders, replacements);
|
this.toFormat = StringFormatter.replacePlaceholders(this.toFormat, placeholders, replacements);
|
||||||
return this;
|
return this;
|
||||||
@@ -61,6 +62,7 @@ public final class FormatBuilder {
|
|||||||
* @param replacement <p>The replacement</p>
|
* @param replacement <p>The replacement</p>
|
||||||
* @return <p>This format builder</p>
|
* @return <p>This format builder</p>
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public FormatBuilder replace(@NotNull String placeholder, @NotNull String replacement) {
|
public FormatBuilder replace(@NotNull String placeholder, @NotNull String replacement) {
|
||||||
this.toFormat = StringFormatter.replacePlaceholder(this.toFormat, placeholder, replacement);
|
this.toFormat = StringFormatter.replacePlaceholder(this.toFormat, placeholder, replacement);
|
||||||
return this;
|
return this;
|
||||||
@@ -73,6 +75,7 @@ public final class FormatBuilder {
|
|||||||
* @param replacement <p>The replacement translatable message</p>
|
* @param replacement <p>The replacement translatable message</p>
|
||||||
* @return <p>This format builder</p>
|
* @return <p>This format builder</p>
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public FormatBuilder replace(@NotNull String placeholder, @NotNull TranslatableMessage replacement) {
|
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));
|
stringFormatter.getUnFormattedMessage(replacement));
|
||||||
@@ -86,6 +89,7 @@ public final class FormatBuilder {
|
|||||||
* @param replacements <p>The replacements</p>
|
* @param replacements <p>The replacements</p>
|
||||||
* @return <p>This format builder</p>
|
* @return <p>This format builder</p>
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public FormatBuilder replace(@NotNull String[] placeholders, @NotNull String[] replacements) {
|
public FormatBuilder replace(@NotNull String[] placeholders, @NotNull String[] replacements) {
|
||||||
this.toFormat = StringFormatter.replacePlaceholders(this.toFormat, placeholders, replacements);
|
this.toFormat = StringFormatter.replacePlaceholders(this.toFormat, placeholders, replacements);
|
||||||
return this;
|
return this;
|
||||||
@@ -97,6 +101,7 @@ public final class FormatBuilder {
|
|||||||
* @param stringReplacer <p>The string replacer used for replacement</p>
|
* @param stringReplacer <p>The string replacer used for replacement</p>
|
||||||
* @return <p>This format builder</p>
|
* @return <p>This format builder</p>
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public FormatBuilder replace(@NotNull StringReplacer stringReplacer) {
|
public FormatBuilder replace(@NotNull StringReplacer stringReplacer) {
|
||||||
this.toFormat = stringReplacer.replace(this.toFormat);
|
this.toFormat = stringReplacer.replace(this.toFormat);
|
||||||
return this;
|
return this;
|
||||||
@@ -110,11 +115,36 @@ public final class FormatBuilder {
|
|||||||
*
|
*
|
||||||
* @return <p>This format builder</p>
|
* @return <p>This format builder</p>
|
||||||
*/
|
*/
|
||||||
|
@NotNull
|
||||||
public FormatBuilder color() {
|
public FormatBuilder color() {
|
||||||
this.toFormat = stringFormatter.getUnFormattedColoredMessage(this.toFormat);
|
this.toFormat = stringFormatter.getUnFormattedColoredMessage(this.toFormat);
|
||||||
return this;
|
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
|
* Builds the output of the performed replacements and formatting
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user