3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 04:20:08 +01:00

SPIGOT-3553: Add OfflinePlayer based methods to SkullMeta

Dieser Commit ist enthalten in:
md_5 2017-09-06 16:14:21 +10:00
Ursprung 178caf9ac2
Commit 9e3636d82a

Datei anzeigen

@ -6,7 +6,9 @@ import net.minecraft.server.GameProfileSerializer;
import net.minecraft.server.NBTBase; import net.minecraft.server.NBTBase;
import net.minecraft.server.NBTTagCompound; import net.minecraft.server.NBTTagCompound;
import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.serialization.DelegateDeserialization; import org.bukkit.configuration.serialization.DelegateDeserialization;
import org.bukkit.craftbukkit.inventory.CraftMetaItem.SerializableMeta; import org.bukkit.craftbukkit.inventory.CraftMetaItem.SerializableMeta;
import org.bukkit.craftbukkit.util.CraftMagicNumbers; import org.bukkit.craftbukkit.util.CraftMagicNumbers;
@ -111,6 +113,21 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
return hasOwner() ? profile.getName() : null; 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) { public boolean setOwner(String name) {
if (name != null && name.length() > MAX_OWNER_LENGTH) { if (name != null && name.length() > MAX_OWNER_LENGTH) {
return false; return false;
@ -125,6 +142,13 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
return true; return true;
} }
@Override
public boolean setOwningPlayer(OfflinePlayer owner) {
profile = (owner == null) ? null : new GameProfile(owner.getUniqueId(), owner.getName());
return true;
}
@Override @Override
int applyHash() { int applyHash() {
final int original; final int original;