2021-06-11 14:02:28 +02: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
2024-07-17 19:24:53 +02:00
index 08838e17979b59555adc242ccdd7af7cbf11f9d6..23374a104510025fd8f882361a29825d0bec6ee0 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java
2024-04-24 03:25:14 +02:00
@@ -98,7 +98,22 @@ public class CraftSkull extends CraftBlockEntityState<SkullBlockEntity> implemen
2021-06-11 14:02:28 +02:00
}
}
+ // Paper start
2022-02-12 14:20:33 +01:00
@Override
+ public void setPlayerProfile(com.destroystokyo.paper.profile.PlayerProfile profile) {
2021-06-11 14:02:28 +02:00
+ Preconditions.checkNotNull(profile, "profile");
2022-02-12 14:20:33 +01:00
+ this.profile = com.destroystokyo.paper.profile.CraftPlayerProfile.asAuthlibCopy(profile);
2021-06-11 14:02:28 +02:00
+ }
+
2021-06-12 18:56:13 +02:00
+ @javax.annotation.Nullable
2021-06-11 14:02:28 +02:00
+ @Override
2022-02-12 14:20:33 +01:00
+ public com.destroystokyo.paper.profile.PlayerProfile getPlayerProfile() {
+ return profile != null ? com.destroystokyo.paper.profile.CraftPlayerProfile.asBukkitCopy(profile) : null;
2021-06-11 14:02:28 +02:00
+ }
+ // Paper end
+
2022-02-12 14:20:33 +01:00
+ @Override
+ @Deprecated // Paper
public PlayerProfile getOwnerProfile() {
if (!this.hasOwner()) {
return null;
2024-04-24 03:25:14 +02:00
@@ -108,11 +123,12 @@ public class CraftSkull extends CraftBlockEntityState<SkullBlockEntity> implemen
2022-02-12 14:20:33 +01:00
}
2021-06-11 14:02:28 +02:00
@Override
2022-02-12 14:20:33 +01: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 14:02:28 +02:00
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
2024-06-15 18:28:18 +02:00
index a36fcd9bfcbd2b37d7cf40b32abc0aea2761ce15..d6e161374e0235031128a6ee86d1ffa875ea48aa 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
2024-06-15 18:28:18 +02:00
@@ -153,6 +153,19 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
2021-06-12 18:56:13 +02:00
return this.hasOwner() ? this.profile.getName() : null;
2021-06-11 14:02:28 +02:00
}
+ // Paper start
+ @Override
2022-02-15 11:30:58 +01:00
+ public void setPlayerProfile(@org.jetbrains.annotations.Nullable com.destroystokyo.paper.profile.PlayerProfile profile) {
2022-02-12 14:20:33 +01:00
+ setProfile((profile == null) ? null : com.destroystokyo.paper.profile.CraftPlayerProfile.asAuthlibCopy(profile));
2021-06-11 14:02:28 +02:00
+ }
+
2022-02-15 11:30:58 +01:00
+ @org.jetbrains.annotations.Nullable
2021-06-11 14:02:28 +02:00
+ @Override
2022-02-12 14:20:33 +01:00
+ public com.destroystokyo.paper.profile.PlayerProfile getPlayerProfile() {
+ return profile != null ? com.destroystokyo.paper.profile.CraftPlayerProfile.asBukkitCopy(profile) : null;
2021-06-11 14:02:28 +02:00
+ }
+ // Paper end
+
@Override
public OfflinePlayer getOwningPlayer() {
2021-06-12 18:56:13 +02:00
if (this.hasOwner()) {
2024-06-15 18:28:18 +02:00
@@ -203,6 +216,7 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
2022-02-12 14:20:33 +01:00
}
@Override
+ @Deprecated // Paper
public PlayerProfile getOwnerProfile() {
if (!this.hasOwner()) {
return null;
2024-06-15 18:28:18 +02:00
@@ -212,11 +226,12 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
2022-02-12 14:20:33 +01: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
}
}
2024-06-15 18:28:18 +02:00
@@ -271,7 +286,7 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
2022-02-12 14:20:33 +01:00
super.serialize(builder);
2024-06-13 16:45:27 +02:00
2022-02-15 11:30:58 +01:00
if (this.profile != null) {
2024-06-13 16:45:27 +02:00
- 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
2022-02-12 14:20:33 +01:00
}
2024-06-13 16:45:27 +02:00
2022-12-26 18:53:35 +01:00
NamespacedKey namespacedKeyNB = this.getNoteBlockSound();