From d5eb80049c513dc396aaeafef23483bb5e33d384 Mon Sep 17 00:00:00 2001 From: Brokkonaut Date: Mon, 6 Aug 2018 07:24:55 +0200 Subject: [PATCH] [1.13] Skull block profile api (#1308) Adds #1307 --- ...Add-setPlayerProfile-API-for-Skulls.patch} | 40 +++++++++++++-- ...Add-setPlayerProfile-API-for-Skulls.patch} | 49 +++++++++++++++++-- 2 files changed, 82 insertions(+), 7 deletions(-) rename Spigot-API-Patches/{0079-Add-SkullMeta.setPlayerProfile-API.patch => 0079-Add-setPlayerProfile-API-for-Skulls.patch} (51%) rename Spigot-Server-Patches/{0232-Add-SkullMeta.setPlayerProfile-API.patch => 0232-Add-setPlayerProfile-API-for-Skulls.patch} (50%) diff --git a/Spigot-API-Patches/0079-Add-SkullMeta.setPlayerProfile-API.patch b/Spigot-API-Patches/0079-Add-setPlayerProfile-API-for-Skulls.patch similarity index 51% rename from Spigot-API-Patches/0079-Add-SkullMeta.setPlayerProfile-API.patch rename to Spigot-API-Patches/0079-Add-setPlayerProfile-API-for-Skulls.patch index 8692bf119..f0d7c968d 100644 --- a/Spigot-API-Patches/0079-Add-SkullMeta.setPlayerProfile-API.patch +++ b/Spigot-API-Patches/0079-Add-setPlayerProfile-API-for-Skulls.patch @@ -1,11 +1,45 @@ -From 0a29a32a10268a1478ad045924aa706d7da5685a Mon Sep 17 00:00:00 2001 +From 55e3e61db93e7dba8a19a6f2094fccf3b2fcab2f Mon Sep 17 00:00:00 2001 From: Aikar Date: Fri, 19 Jan 2018 00:29:28 -0500 -Subject: [PATCH] Add SkullMeta.setPlayerProfile API +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/block/Skull.java b/src/main/java/org/bukkit/block/Skull.java +index 92363d33..b83df2f7 100644 +--- a/src/main/java/org/bukkit/block/Skull.java ++++ b/src/main/java/org/bukkit/block/Skull.java +@@ -4,6 +4,8 @@ import org.bukkit.Material; + import org.bukkit.OfflinePlayer; + import org.bukkit.SkullType; + import org.bukkit.block.data.BlockData; ++import com.destroystokyo.paper.profile.PlayerProfile; ++import javax.annotation.Nullable; + + /** + * Represents a captured state of a skull block. +@@ -55,6 +57,20 @@ public interface Skull extends BlockState { + */ + public void setOwningPlayer(OfflinePlayer player); + ++ // Paper start ++ /** ++ * Sets this skull to use the supplied Player Profile, which can include textures already prefilled. ++ * @param profile The profile to set this Skull to use, may not be null ++ */ ++ void setPlayerProfile(PlayerProfile profile); ++ ++ /** ++ * If the skull has an owner, per {@link #hasOwner()}, return the owners {@link PlayerProfile} ++ * @return The profile of the owner, if set ++ */ ++ @Nullable PlayerProfile getPlayerProfile(); ++ // Paper end ++ + /** + * Gets the rotation of the skull in the world + * diff --git a/src/main/java/org/bukkit/inventory/meta/SkullMeta.java b/src/main/java/org/bukkit/inventory/meta/SkullMeta.java index 15c1dfd9..a458000f 100644 --- a/src/main/java/org/bukkit/inventory/meta/SkullMeta.java @@ -43,5 +77,5 @@ index 15c1dfd9..a458000f 100644 * Gets the owner of the skull. * -- -2.18.0 +2.16.1.windows.1 diff --git a/Spigot-Server-Patches/0232-Add-SkullMeta.setPlayerProfile-API.patch b/Spigot-Server-Patches/0232-Add-setPlayerProfile-API-for-Skulls.patch similarity index 50% rename from Spigot-Server-Patches/0232-Add-SkullMeta.setPlayerProfile-API.patch rename to Spigot-Server-Patches/0232-Add-setPlayerProfile-API-for-Skulls.patch index bbdb513c5..a69e00d43 100644 --- a/Spigot-Server-Patches/0232-Add-SkullMeta.setPlayerProfile-API.patch +++ b/Spigot-Server-Patches/0232-Add-setPlayerProfile-API-for-Skulls.patch @@ -1,13 +1,54 @@ -From df8ebfaa4210ab08be4e6555bd8ebd08353a8a39 Mon Sep 17 00:00:00 2001 +From 72c9d4a3673cc9e9bff91d550b9fd598b38df04f Mon Sep 17 00:00:00 2001 From: Aikar Date: Fri, 19 Jan 2018 00:36:25 -0500 -Subject: [PATCH] Add SkullMeta.setPlayerProfile API +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 +index f113da713..fdfe101ae 100644 +--- a/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java ++++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java +@@ -1,5 +1,7 @@ + package org.bukkit.craftbukkit.block; + ++import com.destroystokyo.paper.profile.CraftPlayerProfile; ++import com.destroystokyo.paper.profile.PlayerProfile; + import com.google.common.base.Preconditions; + import com.mojang.authlib.GameProfile; + import net.minecraft.server.MinecraftServer; +@@ -13,6 +15,7 @@ import org.bukkit.block.Block; + import org.bukkit.block.BlockFace; + import org.bukkit.block.Skull; + import org.bukkit.block.data.Rotatable; ++import javax.annotation.Nullable; + + public class CraftSkull extends CraftBlockEntityState implements Skull { + +@@ -99,6 +102,20 @@ public class CraftSkull extends CraftBlockEntityState implement + this.profile = new GameProfile(player.getUniqueId(), player.getName()); + } + ++ // Paper start ++ @Override ++ public void setPlayerProfile(PlayerProfile profile) { ++ Preconditions.checkNotNull(profile, "profile"); ++ this.profile = CraftPlayerProfile.asAuthlibCopy(profile); ++ } ++ ++ @Nullable ++ @Override ++ public PlayerProfile getPlayerProfile() { ++ return profile != null ? CraftPlayerProfile.asBukkitCopy(profile) : null; ++ } ++ // Paper end ++ + @Override + public BlockFace getRotation() { + return ((Rotatable) getBlockData()).getRotation(); diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java -index 7984c68cb0..14d8dd65ac 100644 +index 7984c68cb..14d8dd65a 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java @@ -2,6 +2,8 @@ package org.bukkit.craftbukkit.inventory; @@ -49,5 +90,5 @@ index 7984c68cb0..14d8dd65ac 100644 public OfflinePlayer getOwningPlayer() { if (hasOwner()) { -- -2.18.0 +2.16.1.windows.1