[1.13] Skull block profile api (#1308)

Adds #1307
This commit is contained in:
Brokkonaut 2018-08-06 07:24:55 +02:00
parent 57e7f2a19d
commit e9cbd7b668
2 changed files with 78 additions and 3 deletions

View file

@ -1,11 +1,45 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Fri, 19 Jan 2018 00:29:28 -0500 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 This allows you to create already filled textures on Skulls to avoid texture lookups
which commonly cause rate limit issues with Mojang API 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
@@ -0,0 +0,0 @@ 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.
@@ -0,0 +0,0 @@ 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 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 index 15c1dfd9..a458000f 100644
--- a/src/main/java/org/bukkit/inventory/meta/SkullMeta.java --- a/src/main/java/org/bukkit/inventory/meta/SkullMeta.java

View file

@ -1,13 +1,54 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co> From: Aikar <aikar@aikar.co>
Date: Fri, 19 Jan 2018 00:36:25 -0500 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 This allows you to create already filled textures on Skulls to avoid texture lookups
which commonly cause rate limit issues with Mojang API 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
@@ -0,0 +0,0 @@
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;
@@ -0,0 +0,0 @@ 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<TileEntitySkull> implements Skull {
@@ -0,0 +0,0 @@ public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> 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 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 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
@@ -0,0 +0,0 @@ package org.bukkit.craftbukkit.inventory; @@ -0,0 +0,0 @@ package org.bukkit.craftbukkit.inventory;