summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPepich <benedikt.abel@yahoo.de>2017-07-08 12:45:27 +0200
committerPepich <benedikt.abel@yahoo.de>2017-07-08 12:45:27 +0200
commit110e5996328bd977693ada88a324b257eafa9914 (patch)
tree81c99374fa87e40601606903b7db217c6c03a3fc
parent5855fce2e46372435185f1f1a185555220f69388 (diff)
Added getID method
-rw-r--r--src/com/redstoner/misc/Utils.java26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/com/redstoner/misc/Utils.java b/src/com/redstoner/misc/Utils.java
index 98081a0..f094b20 100644
--- a/src/com/redstoner/misc/Utils.java
+++ b/src/com/redstoner/misc/Utils.java
@@ -16,10 +16,10 @@ import com.redstoner.coremods.debugger.Debugger;
/** The utils class containing utility functions. Those include but are not limited to sending formatted messages, broadcasts and more.
*
* @author Pepich */
-@Version(major = 4, minor = 0, revision = 1, compatible = 1)
+@Version(major = 4, minor = 0, revision = 2, compatible = 1)
public final class Utils
{
- /** The SimpleDateFormat used for getting the current date. */
+ /** The @SimpleDateFormat used for getting the current date. */
public static SimpleDateFormat dateFormat = new SimpleDateFormat("[yyyy-MM-dd HH:mm:ss]");
/** Hidden constructor. Do not instantiate UTILS classes! :) */
@@ -241,10 +241,10 @@ public final class Utils
return dateFormat.format(date);
}
- /** Provides a uniform way of getting the (display)name of a CommandSender.
+ /** 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. */
+ * @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)
@@ -253,6 +253,20 @@ public final class Utils
return "ยง9" + sender.getName();
}
+ /** Provides a uniform way of getting the UUID of a @CommandSender.
+ *
+ * @param sender The @CommandSender to get the UUID of.
+ * @return The UUID of the @CommandSender or if not a player, "CONSOLE" in blue. */
+ public static String getID(CommandSender sender)
+ {
+ String id;
+ if (sender instanceof Player)
+ id = ((Player) sender).getUniqueId().toString();
+ else
+ id = "CONSOLE";
+ return id;
+ }
+
/** This method "colorifies" a message.
*
* @param message the message to be colored.
@@ -265,7 +279,7 @@ public final class Utils
/** 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.
+ * @param sender the @CommandSender whose permissions shall be applied.
* @return the colorified message. */
public static String colorify(String message, CommandSender sender, char alternateColorcode)
{