Commits
blablubbabc authored and md_5 committed 8f361ecec0c
7 7 | import org.bukkit.Bukkit; |
8 8 | import org.bukkit.OfflinePlayer; |
9 9 | import org.bukkit.SkullType; |
10 10 | import org.bukkit.World; |
11 11 | import org.bukkit.block.BlockFace; |
12 12 | import org.bukkit.block.Skull; |
13 13 | import org.bukkit.block.data.BlockData; |
14 14 | import org.bukkit.block.data.Directional; |
15 15 | import org.bukkit.block.data.Rotatable; |
16 16 | import org.bukkit.craftbukkit.entity.CraftPlayer; |
17 + | import org.bukkit.craftbukkit.profile.CraftPlayerProfile; |
18 + | import org.bukkit.profile.PlayerProfile; |
17 19 | |
18 20 | public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implements Skull { |
19 21 | |
20 22 | private static final int MAX_OWNER_LENGTH = 16; |
21 23 | private GameProfile profile; |
22 24 | |
23 25 | public CraftSkull(World world, TileEntitySkull tileEntity) { |
24 26 | super(world, tileEntity); |
25 27 | } |
26 28 | |
93 95 | public void setOwningPlayer(OfflinePlayer player) { |
94 96 | Preconditions.checkNotNull(player, "player"); |
95 97 | |
96 98 | if (player instanceof CraftPlayer) { |
97 99 | this.profile = ((CraftPlayer) player).getProfile(); |
98 100 | } else { |
99 101 | this.profile = new GameProfile(player.getUniqueId(), player.getName()); |
100 102 | } |
101 103 | } |
102 104 | |
105 + | |
106 + | public PlayerProfile getOwnerProfile() { |
107 + | if (!hasOwner()) { |
108 + | return null; |
109 + | } |
110 + | |
111 + | return new CraftPlayerProfile(profile); |
112 + | } |
113 + | |
114 + | |
115 + | public void setOwnerProfile(PlayerProfile profile) { |
116 + | if (profile == null) { |
117 + | this.profile = null; |
118 + | } else { |
119 + | this.profile = CraftPlayerProfile.validateSkullProfile(((CraftPlayerProfile) profile).buildGameProfile()); |
120 + | } |
121 + | } |
122 + | |
103 123 | |
104 124 | public BlockFace getRotation() { |
105 125 | BlockData blockData = getBlockData(); |
106 126 | return (blockData instanceof Rotatable) ? ((Rotatable) blockData).getRotation() : ((Directional) blockData).getFacing(); |
107 127 | } |
108 128 | |
109 129 | |
110 130 | public void setRotation(BlockFace rotation) { |
111 131 | BlockData blockData = getBlockData(); |
112 132 | if (blockData instanceof Rotatable) { |