From 319293a5b26cb349ad0a6be941036077e9c952b4 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Wed, 22 Jun 2016 11:48:31 +0200 Subject: [PATCH] Substring entity uuid in BoardUtil --- .../massivecore/util/BoardUtil.java | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/com/massivecraft/massivecore/util/BoardUtil.java b/src/com/massivecraft/massivecore/util/BoardUtil.java index 9de75e3d..45071bbb 100644 --- a/src/com/massivecraft/massivecore/util/BoardUtil.java +++ b/src/com/massivecraft/massivecore/util/BoardUtil.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -268,9 +269,29 @@ public class BoardUtil extends Engine public static String getKey(Object key) { if (key == null) return null; - if (key instanceof String) return (String)key; - if (key instanceof Player) return ((Player)key).getName(); - if (key instanceof Entity) return ((Entity)key).getUniqueId().toString(); + + if (key instanceof String) + { + String string = (String)key; + return string; + } + + if (key instanceof Player) + { + Player player = (Player)key; + String name = player.getName(); + return name; + } + + if (key instanceof Entity) + { + Entity entity = (Entity)key; + UUID uuid = entity.getUniqueId(); + String string = uuid.toString(); + string = string.substring(0, 16); + return string; + } + throw new IllegalArgumentException(key.toString()); }