summaryrefslogtreecommitdiff
path: root/src/com/redstoner/misc/Utils.java
diff options
context:
space:
mode:
authorPepich <benedikt.abel@yahoo.de>2017-02-05 12:30:31 +0100
committerPepich <benedikt.abel@yahoo.de>2017-02-05 12:30:31 +0100
commit8228d1bec6eb80697f609e38b3e0c48f7b6fcfab (patch)
tree9ee2850c023ac2745dcfc8027b4baf357dc66cf0 /src/com/redstoner/misc/Utils.java
parentf8c2665c84fb3f0c53a554d9dcc2b91f1b0b019f (diff)
Added color translating broadcast method
Diffstat (limited to 'src/com/redstoner/misc/Utils.java')
-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 9cd4442..188e8fd 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 = 6, compatible = 1)
+@Version(major = 1, minor = 1, revision = 7, compatible = 1)
public final class Utils
{
/** Hidden constructor. Do not instantiate UTILS classes! :) */
@@ -90,6 +90,22 @@ public final class Utils
return broadcast(prefix, message, filter, null);
}
+ /** This method broadcasts a message to all players (and console) that are allowed by the filter. Set the filter to NULL to broadcast to everyone.</br>
+ * This will not be logged to console except when you return true in the filter.
+ *
+ * @param message the message to be sent around
+ * @param filter the BroadcastFilter to be applied.</br>
+ * Write a class implementing the interface and pass it to this method, the "sendTo()" method will be called for each recipient.
+ * @param alternateColorCode The alternate color code indicator to use. If set to '&' then "&7" would be translated to "§7". Works with any char.
+ * @return the amount of people that received the message. */
+ public static int broadcast(String prefix, String message, BroadcastFilter filter, char alternateColorCode)
+ {
+ if (prefix == null)
+ prefix = "§8[§c" + getCaller() + "§8]: ";
+ return broadcast(ChatColor.translateAlternateColorCodes(alternateColorCode, prefix),
+ ChatColor.translateAlternateColorCodes(alternateColorCode, message), filter, null);
+ }
+
/** This method broadcasts a message to all players and console that are allowed by the filter. Set the filter to NULL to broadcast to everyone.</br>
* If you want to, you can set a message that will be logged to console. Set to null to not log anything.</br>
* You can still allow console in the filter to log the original message.