From 41b178b4556992879465a5accd03e0f2c2417a2d Mon Sep 17 00:00:00 2001 From: Pepich Date: Thu, 2 Feb 2017 19:16:44 +0100 Subject: [PATCH] Stopped sendMessage from breaking with null prefix and color code --- src/com/redstoner/misc/Utils.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java index 8f9761f..1bf7ba9 100644 --- a/src/com/redstoner/misc/Utils.java +++ b/src/com/redstoner/misc/Utils.java @@ -13,7 +13,7 @@ import net.md_5.bungee.api.ChatColor; /** The utils class containing utility functions. Those include but are not limited to sending formatted messages, broadcasts and more. * * @author Pepich */ -@Version(major = 1, minor = 1, revision = 4, compatible = 1) +@Version(major = 1, minor = 1, revision = 5, compatible = 1) public final class Utils { /** Hidden constructor. Do not instantiate UTILS classes! :) */ @@ -58,6 +58,8 @@ public final class Utils * @param alternateColorCode The alternate color code indicator to use. If set to '&' then "&7" would be translated to "§7". Works with any char. */ public static void sendMessage(CommandSender recipient, String prefix, String message, char alternateColorCode) { + if (prefix == null) + prefix = "§8[§c" + getCaller() + "§8]: "; sendMessage(recipient, ChatColor.translateAlternateColorCodes(alternateColorCode, prefix), ChatColor.translateAlternateColorCodes(alternateColorCode, message)); } @@ -70,6 +72,8 @@ public final class Utils * @param alternateColorCode The alternate color code indicator to use. If set to '&' then "&7" would be translated to "§7". Works with any char. */ public static void sendErrorMessage(CommandSender recipient, String prefix, String message, char alternateColorCode) { + if (prefix == null) + prefix = "§8[§c" + getCaller() + "§8]: "; sendErrorMessage(recipient, ChatColor.translateAlternateColorCodes(alternateColorCode, prefix), ChatColor.translateAlternateColorCodes(alternateColorCode, message)); }