summaryrefslogtreecommitdiffstats
path: root/src/main/java/org
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2018-09-06 20:47:37 +1000
committermd_5 <git@md-5.net>2018-09-06 20:47:37 +1000
commit3eb8af2340360fdc46db999cb289afdbad6ff2ae (patch)
tree6466db31dec5669269b14bc0021793d3ed09c28e /src/main/java/org
parentc88ae6b1953fd60b724a2b8e555499b5d0acaa00 (diff)
downloadcraftbukkit-3eb8af2340360fdc46db999cb289afdbad6ff2ae.tar
craftbukkit-3eb8af2340360fdc46db999cb289afdbad6ff2ae.tar.gz
craftbukkit-3eb8af2340360fdc46db999cb289afdbad6ff2ae.tar.lz
craftbukkit-3eb8af2340360fdc46db999cb289afdbad6ff2ae.tar.xz
craftbukkit-3eb8af2340360fdc46db999cb289afdbad6ff2ae.zip
SPIGOT-4348: Use online player for setting skull owner if possible
Diffstat (limited to 'src/main/java/org')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java7
-rw-r--r--src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java9
2 files changed, 14 insertions, 2 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java b/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java
index f113da71..ad7a2dd1 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftSkull.java
@@ -13,6 +13,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.Skull;
import org.bukkit.block.data.Rotatable;
+import org.bukkit.craftbukkit.entity.CraftPlayer;
public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implements Skull {
@@ -96,7 +97,11 @@ public class CraftSkull extends CraftBlockEntityState<TileEntitySkull> implement
public void setOwningPlayer(OfflinePlayer player) {
Preconditions.checkNotNull(player, "player");
- this.profile = new GameProfile(player.getUniqueId(), player.getName());
+ if (player instanceof CraftPlayer) {
+ this.profile = ((CraftPlayer) player).getProfile();
+ } else {
+ this.profile = new GameProfile(player.getUniqueId(), player.getName());
+ }
}
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
index b513120e..bedb01cb 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
@@ -11,6 +11,7 @@ import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.serialization.DelegateDeserialization;
+import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.craftbukkit.inventory.CraftMetaItem.SerializableMeta;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
import org.bukkit.inventory.meta.SkullMeta;
@@ -159,7 +160,13 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
@Override
public boolean setOwningPlayer(OfflinePlayer owner) {
- profile = (owner == null) ? null : new GameProfile(owner.getUniqueId(), owner.getName());
+ if (owner == null) {
+ profile = null;
+ } else if (owner instanceof CraftPlayer) {
+ profile = ((CraftPlayer) owner).getProfile();
+ } else {
+ profile = new GameProfile(owner.getUniqueId(), owner.getName());
+ }
return true;
}