diff --git a/pom.xml b/pom.xml
index 75e596a..8e3782b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -90,5 +90,11 @@
The color conversion to use
+ */ + public void setColorConversion(@NotNull ColorConversion colorConversion) { + this.colorConversion = colorConversion; + } + + /** + * Sets the prefix used in front of the plugin name. Normally just "[" + * + * @param namePrefixThe new name prefix
+ */ + public void setNamePrefix(@NotNull String namePrefix) { + this.namePrefix = namePrefix; + } + + /** + * Sets the suffix used after the plugin name. Normally just "]" + * + * @param nameSuffixThe new name suffix
+ */ + public void setNameSuffix(@NotNull String nameSuffix) { + this.nameSuffix = nameSuffix; + } + /** * Sets the color to prepend when using displaySuccessMessage * * @param colorThe color to use
*/ - public void setSuccessColor(ChatColor color) { - if (color != null) { - this.successColor = color; - } else { - throw new IllegalArgumentException("Success color cannot be null"); - } + public void setSuccessColor(@NotNull ChatColor color) { + this.successColor = color; } /** @@ -47,12 +74,8 @@ public final class StringFormatter { * * @param colorThe color to use
*/ - public void setErrorColor(ChatColor color) { - if (color != null) { - this.errorColor = color; - } else { - throw new IllegalArgumentException("Error color cannot be null"); - } + public void setErrorColor(@NotNull ChatColor color) { + this.errorColor = color; } /** @@ -61,7 +84,7 @@ public final class StringFormatter { * @param senderThe command sender to display the message to
* @param messageThe translatable message to display
*/ - public void displayNeutralMessage(CommandSender sender, TranslatableMessage message) { + public void displayNeutralMessage(@NotNull CommandSender sender, @NotNull TranslatableMessage message) { sender.sendMessage(getFormattedMessage(this.translator.getTranslatedMessage(message))); } @@ -71,7 +94,7 @@ public final class StringFormatter { * @param senderThe command sender to display the message to
* @param messageThe raw message to display
*/ - public void displayNeutralMessage(CommandSender sender, String message) { + public void displayNeutralMessage(@NotNull CommandSender sender, @NotNull String message) { sender.sendMessage(getFormattedMessage(message)); } @@ -81,7 +104,7 @@ public final class StringFormatter { * @param senderThe command sender to display the message to
* @param messageThe translatable message to display
*/ - public void displaySuccessMessage(CommandSender sender, TranslatableMessage message) { + public void displaySuccessMessage(@NotNull CommandSender sender, @NotNull TranslatableMessage message) { sender.sendMessage(successColor + getFormattedMessage(this.translator.getTranslatedMessage(message))); } @@ -91,7 +114,7 @@ public final class StringFormatter { * @param senderThe command sender to display the message to
* @param messageThe raw message to display
*/ - public void displaySuccessMessage(CommandSender sender, String message) { + public void displaySuccessMessage(@NotNull CommandSender sender, @NotNull String message) { sender.sendMessage(successColor + getFormattedMessage(message)); } @@ -101,7 +124,7 @@ public final class StringFormatter { * @param senderThe command sender to display the message to
* @param messageThe translatable message to display
*/ - public void displayErrorMessage(CommandSender sender, TranslatableMessage message) { + public void displayErrorMessage(@NotNull CommandSender sender, @NotNull TranslatableMessage message) { sender.sendMessage(errorColor + getFormattedMessage(this.translator.getTranslatedMessage(message))); } @@ -111,7 +134,7 @@ public final class StringFormatter { * @param senderThe command sender to display the message to
* @param messageThe raw message to display
*/ - public void displayErrorMessage(CommandSender sender, String message) { + public void displayErrorMessage(@NotNull CommandSender sender, @NotNull String message) { sender.sendMessage(errorColor + getFormattedMessage(message)); } @@ -123,7 +146,8 @@ public final class StringFormatter { * @param replacementThe replacement value
* @returnThe input string with the placeholder replaced
*/ - public String replacePlaceholder(TranslatableMessage translatableMessage, String placeholder, String replacement) { + public String replacePlaceholder(@NotNull TranslatableMessage translatableMessage, @NotNull String placeholder, + @NotNull String replacement) { return replacePlaceholder(this.translator.getTranslatedMessage(translatableMessage), placeholder, replacement); } @@ -135,8 +159,8 @@ public final class StringFormatter { * @param replacementsThe replacement values
* @returnThe input string with placeholders replaced
*/ - public String replacePlaceholders(TranslatableMessage translatableMessage, String[] placeholders, - String[] replacements) { + public String replacePlaceholders(@NotNull TranslatableMessage translatableMessage, @NotNull String[] placeholders, + @NotNull String[] replacements) { return replacePlaceholders(this.translator.getTranslatedMessage(translatableMessage), placeholders, replacements); } @@ -148,7 +172,8 @@ public final class StringFormatter { * @param replacementThe replacement value
* @returnThe input string with the placeholder replaced
*/ - public static String replacePlaceholder(String input, String placeholder, String replacement) { + public static String replacePlaceholder(@NotNull String input, @NotNull String placeholder, + @NotNull String replacement) { return input.replace(placeholder, replacement); } @@ -160,7 +185,8 @@ public final class StringFormatter { * @param replacementsThe replacement values
* @returnThe input string with placeholders replaced
*/ - public static String replacePlaceholders(String input, String[] placeholders, String[] replacements) { + public static String replacePlaceholders(@NotNull String input, @NotNull String[] placeholders, + @NotNull String[] replacements) { for (int i = 0; i < Math.min(placeholders.length, replacements.length); i++) { input = replacePlaceholder(input, placeholders[i], replacements[i]); } @@ -173,12 +199,14 @@ public final class StringFormatter { * @param messageThe message to format
* @returnThe formatted message
*/ - private String getFormattedMessage(String message) { - message = ColorHelper.translateColorCodes(message, ColorConversion.NORMAL); + private String getFormattedMessage(@NotNull String message) { + message = ColorHelper.translateColorCodes(message, this.colorConversion); if (this.pluginName == null) { return message; } else { - return "[" + this.pluginName + "] " + ChatColor.RESET + message; + String coloredPrefix = ColorHelper.translateColorCodes(namePrefix + ChatColor.RESET + + this.pluginName + ChatColor.RESET + nameSuffix, this.colorConversion); + return coloredPrefix + " " + ChatColor.RESET + message; } }