mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-10 10:17:38 +01:00
SPIGOT-3553: Add OfflinePlayer based methods to SkullMeta
By: md_5 <git@md-5.net>
This commit is contained in:
parent
d68b0a0f44
commit
e594b59798
@ -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