2019-05-14 02:20:58 +00:00
|
|
|
From aaaac679239827b55e690edffe62cddc8f082a29 Mon Sep 17 00:00:00 2001
|
2018-01-19 05:38:49 +00:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Fri, 19 Jan 2018 00:36:25 -0500
|
2018-08-06 05:24:55 +00:00
|
|
|
Subject: [PATCH] Add setPlayerProfile API for Skulls
|
2018-01-19 05:38:49 +00:00
|
|
|
|
|
|
|
This allows you to create already filled textures on Skulls to avoid texture lookups
|
|
|
|
which commonly cause rate limit issues with Mojang API
|
|
|
|
|
2018-08-06 05:24:55 +00:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java
|
2019-05-14 02:20:58 +00:00
|
|
|
index a4bc7f970..2dd2f476f 100644
|
2018-08-06 05:24:55 +00:00
|
|
|
--- 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;
|
2019-04-28 17:59:47 +00:00
|
|
|
@@ -15,6 +17,7 @@ import org.bukkit.block.data.BlockData;
|
2018-10-27 04:02:22 +00:00
|
|
|
import org.bukkit.block.data.Directional;
|
2018-08-06 05:24:55 +00:00
|
|
|
import org.bukkit.block.data.Rotatable;
|
2018-09-07 02:08:35 +00:00
|
|
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
2018-08-06 05:24:55 +00:00
|
|
|
+import javax.annotation.Nullable;
|
|
|
|
|
|
|
|
public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implements Skull {
|
|
|
|
|
2019-04-28 17:59:47 +00:00
|
|
|
@@ -105,6 +108,20 @@ public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implement
|
2018-09-07 02:08:35 +00:00
|
|
|
}
|
2018-08-06 05:24:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+ // 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() {
|
2018-10-27 04:02:22 +00:00
|
|
|
BlockData blockData = getBlockData();
|
2018-01-19 05:38:49 +00:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
2019-05-14 02:20:58 +00:00
|
|
|
index 0136e1bfe..aee97b9f0 100644
|
2018-01-19 05:38:49 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
2019-04-28 17:59:47 +00:00
|
|
|
@@ -3,6 +3,8 @@ package org.bukkit.craftbukkit.inventory;
|
|
|
|
import com.google.common.collect.ImmutableMap.Builder;
|
|
|
|
import com.mojang.authlib.GameProfile;
|
2018-01-19 05:38:49 +00:00
|
|
|
import java.util.Map;
|
|
|
|
+import com.destroystokyo.paper.profile.CraftPlayerProfile;
|
|
|
|
+import com.destroystokyo.paper.profile.PlayerProfile;
|
|
|
|
import net.minecraft.server.GameProfileSerializer;
|
|
|
|
import net.minecraft.server.NBTBase;
|
|
|
|
import net.minecraft.server.NBTTagCompound;
|
2019-04-28 17:59:47 +00:00
|
|
|
@@ -16,6 +18,7 @@ import org.bukkit.craftbukkit.inventory.CraftMetaItem.SerializableMeta;
|
|
|
|
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
|
|
|
import org.bukkit.inventory.meta.SkullMeta;
|
2018-01-19 05:38:49 +00:00
|
|
|
|
|
|
|
+import javax.annotation.Nullable;
|
|
|
|
@DelegateDeserialization(SerializableMeta.class)
|
|
|
|
class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
|
|
|
|
2019-05-06 02:58:04 +00:00
|
|
|
@@ -131,6 +134,19 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
2018-01-19 05:38:49 +00:00
|
|
|
return hasOwner() ? profile.getName() : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start
|
|
|
|
+ @Override
|
|
|
|
+ public void setPlayerProfile(@Nullable PlayerProfile profile) {
|
|
|
|
+ this.profile = (profile == null) ? null : CraftPlayerProfile.asAuthlibCopy(profile);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Nullable
|
|
|
|
+ @Override
|
|
|
|
+ public PlayerProfile getPlayerProfile() {
|
2018-03-23 03:32:55 +00:00
|
|
|
+ return profile != null ? CraftPlayerProfile.asBukkitCopy(profile) : null;
|
2018-01-19 05:38:49 +00:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public OfflinePlayer getOwningPlayer() {
|
|
|
|
if (hasOwner()) {
|
|
|
|
--
|
2019-03-20 01:46:00 +00:00
|
|
|
2.21.0
|
2018-01-19 05:38:49 +00:00
|
|
|
|