summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTravis Watkins <amaranth@ubuntu.com>2014-04-17 08:41:29 -0500
committerTravis Watkins <amaranth@ubuntu.com>2014-04-17 08:41:29 -0500
commita8d5c1224f93f2b8fcdd2acb20ae11fc92336cb6 (patch)
treef3309abe4e04ad3896f0402e29df3074b4530afc
parent6ad36f09e5173baa3b8f464bae4d0d20411080ec (diff)
downloadcraftbukkit-a8d5c1224f93f2b8fcdd2acb20ae11fc92336cb6.tar
craftbukkit-a8d5c1224f93f2b8fcdd2acb20ae11fc92336cb6.tar.gz
craftbukkit-a8d5c1224f93f2b8fcdd2acb20ae11fc92336cb6.tar.lz
craftbukkit-a8d5c1224f93f2b8fcdd2acb20ae11fc92336cb6.tar.xz
craftbukkit-a8d5c1224f93f2b8fcdd2acb20ae11fc92336cb6.zip
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.
-rw-r--r--src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java23
1 files 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 d5447605..4e0620e5 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;
}