From 142b0659792e9819e07d86572db54e91b5f2f535 Mon Sep 17 00:00:00 2001 From: Aikar <aikar@aikar.co> Date: Fri, 19 Jan 2018 00:29:28 -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 --- .../src/main/java/org/bukkit/block/Skull.java | 16 ++++++++++++++++ .../org/bukkit/inventory/meta/SkullMeta.java | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/block/Skull.java b/paper-api/src/main/java/org/bukkit/block/Skull.java index bf2d1b300f..6cb7791e97 100644 --- a/paper-api/src/main/java/org/bukkit/block/Skull.java +++ b/paper-api/src/main/java/org/bukkit/block/Skull.java @@ -63,6 +63,20 @@ public interface Skull extends TileState { */ public void setOwningPlayer(@NotNull 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(@NotNull com.destroystokyo.paper.profile.PlayerProfile profile); + + /** + * If the skull has an owner, per {@link #hasOwner()}, return the owners {@link com.destroystokyo.paper.profile.PlayerProfile} + * @return The profile of the owner, if set + */ + @Nullable com.destroystokyo.paper.profile.PlayerProfile getPlayerProfile(); + // Paper end + /** * Gets the profile of the player who owns the skull. This player profile * may appear as the texture depending on skull type. @@ -70,6 +84,7 @@ public interface Skull extends TileState { * @return the profile of the owning player */ @Nullable + @Deprecated // Paper PlayerProfile getOwnerProfile(); /** @@ -84,6 +99,7 @@ public interface Skull extends TileState { * @throws IllegalArgumentException if the profile does not contain the * necessary information */ + @Deprecated // Paper void setOwnerProfile(@Nullable PlayerProfile profile); /** diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/SkullMeta.java b/paper-api/src/main/java/org/bukkit/inventory/meta/SkullMeta.java index 5af814d3cf..a478b6939d 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/SkullMeta.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/SkullMeta.java @@ -38,6 +38,20 @@ public interface SkullMeta extends ItemMeta { @Deprecated(since = "1.12.1") boolean setOwner(@Nullable String owner); + // 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, or null to clear owner + */ + void setPlayerProfile(@Nullable com.destroystokyo.paper.profile.PlayerProfile profile); + + /** + * If the skull has an owner, per {@link #hasOwner()}, return the owners {@link com.destroystokyo.paper.profile.PlayerProfile} + * @return The profile of the owner, if set + */ + @Nullable com.destroystokyo.paper.profile.PlayerProfile getPlayerProfile(); + // Paper end + /** * Gets the owner of the skull. * @@ -64,6 +78,7 @@ public interface SkullMeta extends ItemMeta { * @return the profile of the owning player */ @Nullable + @Deprecated // Paper PlayerProfile getOwnerProfile(); /** @@ -78,6 +93,7 @@ public interface SkullMeta extends ItemMeta { * @throws IllegalArgumentException if the profile does not contain the * necessary information */ + @Deprecated // Paper void setOwnerProfile(@Nullable PlayerProfile profile); /**