Commits
md_5 authored 0cd0397a829
1 1 | package org.bukkit.craftbukkit.block; |
2 2 | |
3 + | import com.google.common.base.Preconditions; |
3 4 | import com.mojang.authlib.GameProfile; |
4 5 | import net.minecraft.server.MinecraftServer; |
5 6 | import net.minecraft.server.TileEntitySkull; |
7 + | import org.bukkit.Bukkit; |
6 8 | import org.bukkit.Material; |
9 + | import org.bukkit.OfflinePlayer; |
7 10 | |
8 11 | import org.bukkit.SkullType; |
9 12 | import org.bukkit.block.Block; |
10 13 | import org.bukkit.block.BlockFace; |
11 14 | import org.bukkit.block.Skull; |
12 15 | import org.bukkit.craftbukkit.CraftWorld; |
13 16 | |
14 17 | public class CraftSkull extends CraftBlockState implements Skull { |
15 18 | private static final int MAX_OWNER_LENGTH = 16; |
16 19 | private final TileEntitySkull skull; |
169 172 | } |
170 173 | |
171 174 | if (skullType != SkullType.PLAYER) { |
172 175 | skullType = SkullType.PLAYER; |
173 176 | } |
174 177 | |
175 178 | this.profile = profile; |
176 179 | return true; |
177 180 | } |
178 181 | |
182 + | |
183 + | public OfflinePlayer getOwningPlayer() { |
184 + | return hasOwner() ? Bukkit.getOfflinePlayer(profile.getId()) : null; |
185 + | } |
186 + | |
187 + | |
188 + | public void setOwningPlayer(OfflinePlayer player) { |
189 + | Preconditions.checkNotNull(player, "player"); |
190 + | |
191 + | if (skullType != SkullType.PLAYER) { |
192 + | skullType = SkullType.PLAYER; |
193 + | } |
194 + | |
195 + | this.profile = new GameProfile(player.getUniqueId(), player.getName()); |
196 + | } |
197 + | |
179 198 | public BlockFace getRotation() { |
180 199 | return getBlockFace(rotation); |
181 200 | } |
182 201 | |
183 202 | public void setRotation(BlockFace rotation) { |
184 203 | this.rotation = getBlockFace(rotation); |
185 204 | } |
186 205 | |
187 206 | public SkullType getSkullType() { |
188 207 | return skullType; |