diff options
author | md_5 <git@md-5.net> | 2016-06-01 21:39:49 +1000 |
---|---|---|
committer | md_5 <git@md-5.net> | 2016-06-03 20:41:49 +1000 |
commit | 0cd0397a8295992112ad3bf0d37795a04d22503e (patch) | |
tree | ecb346ccd1cbca00ba2c4546dceb4b160f03424e /src | |
parent | a28041daa73e766e0c772e36d2052aa10703d925 (diff) | |
download | craftbukkit-0cd0397a8295992112ad3bf0d37795a04d22503e.tar craftbukkit-0cd0397a8295992112ad3bf0d37795a04d22503e.tar.gz craftbukkit-0cd0397a8295992112ad3bf0d37795a04d22503e.tar.lz craftbukkit-0cd0397a8295992112ad3bf0d37795a04d22503e.tar.xz craftbukkit-0cd0397a8295992112ad3bf0d37795a04d22503e.zip |
SPIGOT-249: Set skull owner by UUID
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java | 19 |
1 files changed, 19 insertions, 0 deletions
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); } |