summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPepich <benedikt.abel@yahoo.de>2017-05-05 10:23:30 +0200
committerPepich <benedikt.abel@yahoo.de>2017-05-05 10:23:30 +0200
commite6625fd37907497d4c69e71e839f58070b4b205b (patch)
treef04fbd487ece199ac797d75d5484322109322791
parentd2e8b5fa36cd4e7c81b4c3ef53feb4e86796e38f (diff)
Moved colorify method into Utils class
-rw-r--r--src/com/redstoner/misc/Utils.java18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java
index 3a51344..ee9a67d 100644
--- a/src/com/redstoner/misc/Utils.java
+++ b/src/com/redstoner/misc/Utils.java
@@ -16,7 +16,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 = 3, revision = 0, compatible = 1)
+@Version(major = 1, minor = 3, revision = 1, compatible = 1)
public final class Utils
{
/** The SimpleDateFormat used for getting the current date. */
@@ -258,4 +258,20 @@ public final class Utils
else
return "&9" + sender.getName();
}
+
+ /** This method "colorifies" a message using proper permissions.
+ *
+ * @param message the message to be colored.
+ * @param sender the command sender whose permissions shall be applied.
+ * @return the colorified message. */
+ public static String colorify(String message, CommandSender sender)
+ {
+ if (sender.hasPermission("essentials.chat.color"))
+ message = message.replaceAll("&([0-9a-fA-FrR])", "§$1");
+ if (sender.hasPermission("essentials.chat.format"))
+ message = message.replaceAll("&(l-oL-OrR)", "§$1");
+ if (sender.hasPermission("essentials.chat.magic"))
+ message = message.replaceAll("&([kKrR])", "§$1");
+ return message.replace("&§", "&");
+ }
}