summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPepich <benedikt.abel@yahoo.de>2017-03-10 20:49:23 +0100
committerPepich <benedikt.abel@yahoo.de>2017-03-10 20:49:23 +0100
commit81c10e62c201183493dbe1f8e1968eaeba7a8751 (patch)
tree7114269665c0020187a267417b9bce69a559dacb
parent4df0754970cbb59a499718774a0a00bc06e6608a (diff)
Added getName method, made documentation more clear
-rw-r--r--src/com/redstoner/misc/Utils.java20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java
index cf78bb8..7012b32 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 = 2, revision = 11, compatible = 1)
+@Version(major = 1, minor = 2, revision = 12, compatible = 1)
public final class Utils
{
/** The SimpleDateFormat used for getting the current date. */
@@ -164,7 +164,7 @@ public final class Utils
info(message);
}
- /** Prints an info message into console. Supports &x color codes.
+ /** Prints an info message into console. Supports "&" color codes.
*
* @param message The message to be put into console. Prefixes are automatically generated. Color defaults to grey. */
@Debugable
@@ -176,7 +176,7 @@ public final class Utils
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + "§7" + message));
}
- /** Prints a warning message into console. Supports &x color codes.
+ /** Prints a warning message into console. Supports "&" color codes.
*
* @param message The message to be put into console. Prefixes are automatically generated. Color defaults to grey. */
@Debugable
@@ -188,7 +188,7 @@ public final class Utils
Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', prefix + "§7" + message));
}
- /** Used to make an error output to console. Supports &x color codes.
+ /** Used to make an error output to console. Supports "&" color codes.
*
* @param message The message to be put into console. Prefixes are automatically generated. Color defaults to red. */
@Debugable
@@ -231,4 +231,16 @@ public final class Utils
Date date = new Date(System.currentTimeMillis());
return dateFormat.format(date);
}
+
+ /** Provides a uniform way of getting the (display)name of a CommandSender.
+ *
+ * @param sender The CommandSender to get the name of.
+ * @return The DisplayName of the CommandSender or if not a player, the name in blue. */
+ public static String getName(CommandSender sender)
+ {
+ if (sender instanceof Player)
+ return ((Player) sender).getDisplayName();
+ else
+ return "&9" + sender.getName();
+ }
}