From 0cd0397a8295992112ad3bf0d37795a04d22503e Mon Sep 17 00:00:00 2001 From: md_5 Date: Wed, 1 Jun 2016 21:39:49 +1000 Subject: SPIGOT-249: Set skull owner by UUID --- .../java/org/bukkit/craftbukkit/block/CraftSkull.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src') diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java index eb1548a0..90572f5a 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); } -- cgit v1.2.3