Substring entity uuid in BoardUtil

This commit is contained in:
Olof Larsson 2016-06-22 11:48:31 +02:00
parent 0b5a5ee1dd
commit 319293a5b2
No known key found for this signature in database
GPG Key ID: BBEF14F97DA52474

View File

@ -5,6 +5,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -268,9 +269,29 @@ public class BoardUtil extends Engine
public static String getKey(Object key) public static String getKey(Object key)
{ {
if (key == null) return null; if (key == null) return null;
if (key instanceof String) return (String)key;
if (key instanceof Player) return ((Player)key).getName(); if (key instanceof String)
if (key instanceof Entity) return ((Entity)key).getUniqueId().toString(); {
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()); throw new IllegalArgumentException(key.toString());
} }