mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 04:55:47 +01:00
SPIGOT-3553: Add OfflinePlayer based methods to SkullMeta
This commit is contained in:
parent
178caf9ac2
commit
9e3636d82a
@ -6,7 +6,9 @@ import net.minecraft.server.GameProfileSerializer;
|
||||
import net.minecraft.server.NBTBase;
|
||||
import net.minecraft.server.NBTTagCompound;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.configuration.serialization.DelegateDeserialization;
|
||||
import org.bukkit.craftbukkit.inventory.CraftMetaItem.SerializableMeta;
|
||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||
@ -111,6 +113,21 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||
return hasOwner() ? profile.getName() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OfflinePlayer getOwningPlayer() {
|
||||
if (hasOwner()) {
|
||||
if (profile.getId() != null) {
|
||||
return Bukkit.getOfflinePlayer(profile.getId());
|
||||
}
|
||||
|
||||
if (profile.getName() != null) {
|
||||
return Bukkit.getOfflinePlayer(profile.getName());
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean setOwner(String name) {
|
||||
if (name != null && name.length() > MAX_OWNER_LENGTH) {
|
||||
return false;
|
||||
@ -125,6 +142,13 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setOwningPlayer(OfflinePlayer owner) {
|
||||
profile = (owner == null) ? null : new GameProfile(owner.getUniqueId(), owner.getName());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
int applyHash() {
|
||||
final int original;
|
||||
|
Loading…
Reference in New Issue
Block a user