2020-05-06 11:48:49 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2018-01-19 06:38:49 +01:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Fri, 19 Jan 2018 00:36:25 -0500
|
2018-08-06 07:24:55 +02:00
|
|
|
Subject: [PATCH] Add setPlayerProfile API for Skulls
|
2018-01-19 06:38:49 +01: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 07:24:55 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java
|
2020-05-06 11:48:49 +02:00
|
|
|
index 20588598386a4f479e6a58b294149bed789c63ce..ecc32c2fb1e8e1ac03074102b982adb4cda169db 100644
|
2018-08-06 07:24:55 +02: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 19:59:47 +02:00
|
|
|
@@ -15,6 +17,7 @@ import org.bukkit.block.data.BlockData;
|
2018-10-27 06:02:22 +02:00
|
|
|
import org.bukkit.block.data.Directional;
|
2018-08-06 07:24:55 +02:00
|
|
|
import org.bukkit.block.data.Rotatable;
|
2018-09-07 04:08:35 +02:00
|
|
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
2018-08-06 07:24:55 +02:00
|
|
|
+import javax.annotation.Nullable;
|
|
|
|
|
|
|
|
public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implements Skull {
|
|
|
|
|
2019-04-28 19:59:47 +02:00
|
|
|
@@ -105,6 +108,20 @@ public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implement
|
2018-09-07 04:08:35 +02:00
|
|
|
}
|
2018-08-06 07:24:55 +02: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 06:02:22 +02:00
|
|
|
BlockData blockData = getBlockData();
|
2018-01-19 06:38:49 +01:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
2021-03-09 00:12:31 +01:00
|
|
|
index 58aeeff96a92b5ba0c3435c680885ad3bc4f4ce6..fba6c1f454fdee3541393e6803d7249cf1fbe6d2 100644
|
2018-01-19 06:38:49 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
2020-09-27 16:52:40 +02:00
|
|
|
@@ -4,6 +4,8 @@ import com.google.common.collect.ImmutableMap.Builder;
|
2019-04-28 19:59:47 +02:00
|
|
|
import com.mojang.authlib.GameProfile;
|
2018-01-19 06:38:49 +01:00
|
|
|
import java.util.Map;
|
2020-09-27 16:52:40 +02:00
|
|
|
import java.util.UUID;
|
2018-01-19 06:38:49 +01:00
|
|
|
+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;
|
2021-03-09 00:12:31 +01:00
|
|
|
@@ -18,6 +20,7 @@ import org.bukkit.craftbukkit.inventory.CraftMetaItem.SerializableMeta;
|
2019-04-28 19:59:47 +02:00
|
|
|
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
|
|
|
import org.bukkit.inventory.meta.SkullMeta;
|
2018-01-19 06:38:49 +01:00
|
|
|
|
|
|
|
+import javax.annotation.Nullable;
|
|
|
|
@DelegateDeserialization(SerializableMeta.class)
|
|
|
|
class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
|
|
|
|
2021-03-09 00:12:31 +01:00
|
|
|
@@ -149,6 +152,19 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
2018-01-19 06:38:49 +01:00
|
|
|
return hasOwner() ? profile.getName() : null;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start
|
|
|
|
+ @Override
|
|
|
|
+ public void setPlayerProfile(@Nullable PlayerProfile profile) {
|
2020-01-10 19:07:29 +01:00
|
|
|
+ setProfile((profile == null) ? null : CraftPlayerProfile.asAuthlibCopy(profile));
|
2018-01-19 06:38:49 +01:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Nullable
|
|
|
|
+ @Override
|
|
|
|
+ public PlayerProfile getPlayerProfile() {
|
2018-03-23 04:32:55 +01:00
|
|
|
+ return profile != null ? CraftPlayerProfile.asBukkitCopy(profile) : null;
|
2018-01-19 06:38:49 +01:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
@Override
|
|
|
|
public OfflinePlayer getOwningPlayer() {
|
|
|
|
if (hasOwner()) {
|