mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
Add setPlayerProfile API for Skulls
This allows you to create already filled textures on Skulls to avoid texture lookups which commonly cause rate limit issues with Mojang API
This commit is contained in:
parent
f249b1f39a
commit
3620489699
2 changed files with 35 additions and 4 deletions
|
@ -98,7 +98,22 @@ public class CraftSkull extends CraftBlockEntityState<SkullBlockEntity> implemen
|
|||
}
|
||||
}
|
||||
|
||||
// Paper start
|
||||
@Override
|
||||
public void setPlayerProfile(com.destroystokyo.paper.profile.PlayerProfile profile) {
|
||||
Preconditions.checkNotNull(profile, "profile");
|
||||
this.profile = com.destroystokyo.paper.profile.CraftPlayerProfile.asResolvableProfileCopy(profile);
|
||||
}
|
||||
|
||||
@javax.annotation.Nullable
|
||||
@Override
|
||||
public com.destroystokyo.paper.profile.PlayerProfile getPlayerProfile() {
|
||||
return profile != null ? new com.destroystokyo.paper.profile.CraftPlayerProfile(profile) : null;
|
||||
}
|
||||
// Paper end
|
||||
|
||||
@Override
|
||||
@Deprecated // Paper
|
||||
public PlayerProfile getOwnerProfile() {
|
||||
if (!this.hasOwner()) {
|
||||
return null;
|
||||
|
@ -108,11 +123,12 @@ public class CraftSkull extends CraftBlockEntityState<SkullBlockEntity> implemen
|
|||
}
|
||||
|
||||
@Override
|
||||
@Deprecated // Paper
|
||||
public void setOwnerProfile(PlayerProfile profile) {
|
||||
if (profile == null) {
|
||||
this.profile = null;
|
||||
} else {
|
||||
this.profile = new ResolvableProfile(CraftPlayerProfile.validateSkullProfile(((CraftPlayerProfile) profile).buildGameProfile()));
|
||||
this.profile = CraftPlayerProfile.validateSkullProfile(((com.destroystokyo.paper.profile.SharedPlayerProfile) profile).buildResolvableProfile()); // Paper
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -148,6 +148,19 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
|||
return this.hasOwner() ? this.profile.name().orElse(null) : null;
|
||||
}
|
||||
|
||||
// Paper start
|
||||
@Override
|
||||
public void setPlayerProfile(@org.jetbrains.annotations.Nullable com.destroystokyo.paper.profile.PlayerProfile profile) {
|
||||
setProfile((profile == null) ? null : com.destroystokyo.paper.profile.CraftPlayerProfile.asResolvableProfileCopy(profile));
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.Nullable
|
||||
@Override
|
||||
public com.destroystokyo.paper.profile.PlayerProfile getPlayerProfile() {
|
||||
return profile != null ? new com.destroystokyo.paper.profile.CraftPlayerProfile(profile) : null;
|
||||
}
|
||||
// Paper end
|
||||
|
||||
@Override
|
||||
public OfflinePlayer getOwningPlayer() {
|
||||
if (this.hasOwner()) {
|
||||
|
@ -198,6 +211,7 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Deprecated // Paper
|
||||
public PlayerProfile getOwnerProfile() {
|
||||
if (!this.hasOwner()) {
|
||||
return null;
|
||||
|
@ -207,9 +221,10 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Deprecated // Paper
|
||||
public void setOwnerProfile(PlayerProfile profile) {
|
||||
if (profile instanceof CraftPlayerProfile craftPlayerProfile) {
|
||||
this.setProfile(CraftPlayerProfile.validateSkullProfile(craftPlayerProfile.buildResolvableProfile()));
|
||||
if (profile instanceof final com.destroystokyo.paper.profile.SharedPlayerProfile sharedProfile) {
|
||||
this.setProfile(CraftPlayerProfile.validateSkullProfile(sharedProfile.buildResolvableProfile())); // Paper
|
||||
} else {
|
||||
this.setProfile(null);
|
||||
}
|
||||
|
@ -263,7 +278,7 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
|||
super.serialize(builder);
|
||||
|
||||
if (this.hasOwner()) {
|
||||
builder.put(CraftMetaSkull.SKULL_OWNER.BUKKIT, new CraftPlayerProfile(this.profile));
|
||||
builder.put(CraftMetaSkull.SKULL_OWNER.BUKKIT, new com.destroystokyo.paper.profile.CraftPlayerProfile(this.profile)); // Paper
|
||||
}
|
||||
|
||||
NamespacedKey namespacedKeyNB = this.getNoteBlockSound();
|
||||
|
|
Loading…
Reference in a new issue