From a8d5c1224f93f2b8fcdd2acb20ae11fc92336cb6 Mon Sep 17 00:00:00 2001 From: Travis Watkins Date: Thu, 17 Apr 2014 08:41:29 -0500 Subject: [PATCH] Make skulls pretend to only use names like before 1.7.8. Any new API here needs more thought, skulls require a name but OfflinePlayer is not guaranteed to have one. There is a Mojang approved way to get a complete profile from a name but not from a UUID so for now just pretend this still only uses names. --- .../bukkit/craftbukkit/block/CraftSkull.java | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java index d54476052b..4e0620e567 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java @@ -14,6 +14,7 @@ import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.entity.CraftPlayer; public class CraftSkull extends CraftBlockState implements Skull { + private static final int MAX_OWNER_LENGTH = 16; private final TileEntitySkull skull; private GameProfile profile; private SkullType skullType; @@ -146,31 +147,23 @@ public class CraftSkull extends CraftBlockState implements Skull { } public String getOwner() { - return profile.getName(); + return hasOwner() ? profile.getName() : null; } public boolean setOwner(String name) { - return false; - } - - public OfflinePlayer getPlayer() { - return MinecraftServer.getServer().server.getOfflinePlayer(profile); - } - - public boolean setPlayer(OfflinePlayer player) { - GameProfile profile; - if (player instanceof CraftPlayer) { - profile = ((CraftPlayer) player).getProfile(); - } else if (player instanceof CraftOfflinePlayer) { - profile = ((CraftOfflinePlayer) player).getProfile(); - } else { + if (name == null || name.length() > MAX_OWNER_LENGTH) { return false; } + GameProfile profile = MinecraftServer.getServer().getUserCache().a(name); if (profile == null) { return false; } + if (skullType != SkullType.PLAYER) { + skullType = SkullType.PLAYER; + } + this.profile = profile; return true; }