mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-23 19:15:32 +01:00
Make skulls pretend to only use names like before 1.7.8.
Any new API here needs more thought, skulls require a name but OfflinePlayer is not guaranteed to have one. There is a Mojang approved way to get a complete profile from a name but not from a UUID so for now just pretend this still only uses names.
This commit is contained in:
parent
6ad36f09e5
commit
a8d5c1224f
@ -14,6 +14,7 @@ import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
|
||||
public class CraftSkull extends CraftBlockState implements Skull {
|
||||
private static final int MAX_OWNER_LENGTH = 16;
|
||||
private final TileEntitySkull skull;
|
||||
private GameProfile profile;
|
||||
private SkullType skullType;
|
||||
@ -146,31 +147,23 @@ public class CraftSkull extends CraftBlockState implements Skull {
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return profile.getName();
|
||||
return hasOwner() ? profile.getName() : null;
|
||||
}
|
||||
|
||||
public boolean setOwner(String name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public OfflinePlayer getPlayer() {
|
||||
return MinecraftServer.getServer().server.getOfflinePlayer(profile);
|
||||
}
|
||||
|
||||
public boolean setPlayer(OfflinePlayer player) {
|
||||
GameProfile profile;
|
||||
if (player instanceof CraftPlayer) {
|
||||
profile = ((CraftPlayer) player).getProfile();
|
||||
} else if (player instanceof CraftOfflinePlayer) {
|
||||
profile = ((CraftOfflinePlayer) player).getProfile();
|
||||
} else {
|
||||
if (name == null || name.length() > MAX_OWNER_LENGTH) {
|
||||
return false;
|
||||
}
|
||||
|
||||
GameProfile profile = MinecraftServer.getServer().getUserCache().a(name);
|
||||
if (profile == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (skullType != SkullType.PLAYER) {
|
||||
skullType = SkullType.PLAYER;
|
||||
}
|
||||
|
||||
this.profile = profile;
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user