2021-06-11 12:02:28 +00:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Fri, 19 Jan 2018 00:36:25 -0500
Subject: [PATCH] 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
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java
2022-02-12 13:20:33 +00:00
index 6ac03706a584e4cb07300cf6e34969a8c4595c58..0be71d9d06f34e9ac58da3bbef954b2786cee53b 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java
2022-02-12 13:20:33 +00:00
@@ -102,7 +102,22 @@ public class CraftSkull extends CraftBlockEntityState<SkullBlockEntity> implemen
2021-06-11 12:02:28 +00:00
}
}
+ // Paper start
2022-02-12 13:20:33 +00:00
@Override
+ public void setPlayerProfile(com.destroystokyo.paper.profile.PlayerProfile profile) {
2021-06-11 12:02:28 +00:00
+ Preconditions.checkNotNull(profile, "profile");
2022-02-12 13:20:33 +00:00
+ this.profile = com.destroystokyo.paper.profile.CraftPlayerProfile.asAuthlibCopy(profile);
2021-06-11 12:02:28 +00:00
+ }
+
2021-06-12 16:56:13 +00:00
+ @javax.annotation.Nullable
2021-06-11 12:02:28 +00:00
+ @Override
2022-02-12 13:20:33 +00:00
+ public com.destroystokyo.paper.profile.PlayerProfile getPlayerProfile() {
+ return profile != null ? com.destroystokyo.paper.profile.CraftPlayerProfile.asBukkitCopy(profile) : null;
2021-06-11 12:02:28 +00:00
+ }
+ // Paper end
+
2022-02-12 13:20:33 +00:00
+ @Override
+ @Deprecated // Paper
public PlayerProfile getOwnerProfile() {
if (!this.hasOwner()) {
return null;
@@ -112,11 +127,12 @@ public class CraftSkull extends CraftBlockEntityState<SkullBlockEntity> implemen
}
2021-06-11 12:02:28 +00:00
@Override
2022-02-12 13:20:33 +00:00
+ @Deprecated // Paper
public void setOwnerProfile(PlayerProfile profile) {
if (profile == null) {
this.profile = null;
} else {
- this.profile = CraftPlayerProfile.validateSkullProfile(((CraftPlayerProfile) profile).buildGameProfile());
+ this.profile = CraftPlayerProfile.validateSkullProfile(((com.destroystokyo.paper.profile.SharedPlayerProfile) profile).buildGameProfile()); // Paper
}
}
2021-06-11 12:02:28 +00:00
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
2022-09-20 01:39:46 +00:00
index 07a6bac294273c94f2f7353aa0514ced24c4a93e..92b56f16b4d8107ccf206be6b81a98dc58986c10 100644
2021-06-11 12:02:28 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
2022-02-15 10:30:58 +00:00
@@ -143,6 +143,19 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
2021-06-12 16:56:13 +00:00
return this.hasOwner() ? this.profile.getName() : null;
2021-06-11 12:02:28 +00:00
}
+ // Paper start
+ @Override
2022-02-15 10:30:58 +00:00
+ public void setPlayerProfile(@org.jetbrains.annotations.Nullable com.destroystokyo.paper.profile.PlayerProfile profile) {
2022-02-12 13:20:33 +00:00
+ setProfile((profile == null) ? null : com.destroystokyo.paper.profile.CraftPlayerProfile.asAuthlibCopy(profile));
2021-06-11 12:02:28 +00:00
+ }
+
2022-02-15 10:30:58 +00:00
+ @org.jetbrains.annotations.Nullable
2021-06-11 12:02:28 +00:00
+ @Override
2022-02-12 13:20:33 +00:00
+ public com.destroystokyo.paper.profile.PlayerProfile getPlayerProfile() {
+ return profile != null ? com.destroystokyo.paper.profile.CraftPlayerProfile.asBukkitCopy(profile) : null;
2021-06-11 12:02:28 +00:00
+ }
+ // Paper end
+
@Override
public OfflinePlayer getOwningPlayer() {
2021-06-12 16:56:13 +00:00
if (this.hasOwner()) {
2022-02-15 10:30:58 +00:00
@@ -193,6 +206,7 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
2022-02-12 13:20:33 +00:00
}
@Override
+ @Deprecated // Paper
public PlayerProfile getOwnerProfile() {
if (!this.hasOwner()) {
return null;
2022-02-15 10:30:58 +00:00
@@ -202,11 +216,12 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
2022-02-12 13:20:33 +00:00
}
@Override
+ @Deprecated // Paper
public void setOwnerProfile(PlayerProfile profile) {
if (profile == null) {
this.setProfile(null);
} else {
- this.setProfile(CraftPlayerProfile.validateSkullProfile(((CraftPlayerProfile) profile).buildGameProfile()));
+ this.setProfile(CraftPlayerProfile.validateSkullProfile(((com.destroystokyo.paper.profile.SharedPlayerProfile) profile).buildGameProfile())); // Paper
}
}
2022-02-15 10:30:58 +00:00
@@ -243,7 +258,7 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
2022-02-12 13:20:33 +00:00
Builder<String, Object> serialize(Builder<String, Object> builder) {
super.serialize(builder);
2022-02-15 10:30:58 +00:00
if (this.profile != null) {
2022-02-12 13:20:33 +00:00
- return builder.put(SKULL_OWNER.BUKKIT, new CraftPlayerProfile(this.profile));
+ return builder.put(SKULL_OWNER.BUKKIT, new com.destroystokyo.paper.profile.CraftPlayerProfile(this.profile)); // Paper
}
return builder;
}