diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java index eb1548a0df..90572f5a15 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java @@ -1,9 +1,12 @@ package org.bukkit.craftbukkit.block; +import com.google.common.base.Preconditions; import com.mojang.authlib.GameProfile; import net.minecraft.server.MinecraftServer; import net.minecraft.server.TileEntitySkull; +import org.bukkit.Bukkit; import org.bukkit.Material; +import org.bukkit.OfflinePlayer; import org.bukkit.SkullType; import org.bukkit.block.Block; @@ -176,6 +179,22 @@ public class CraftSkull extends CraftBlockState implements Skull { return true; } + @Override + public OfflinePlayer getOwningPlayer() { + return hasOwner() ? Bukkit.getOfflinePlayer(profile.getId()) : null; + } + + @Override + public void setOwningPlayer(OfflinePlayer player) { + Preconditions.checkNotNull(player, "player"); + + if (skullType != SkullType.PLAYER) { + skullType = SkullType.PLAYER; + } + + this.profile = new GameProfile(player.getUniqueId(), player.getName()); + } + public BlockFace getRotation() { return getBlockFace(rotation); }