Fix NPE on TileEntitySkull (#3598)
The setGameProfile method on TileEntitySkull is annotated with the @nullable annotation, but the skull didn't check for null profiles before attempting to retrieve cached skin. This bug was introduced by the commit making the skull use spigot's User Cache. Additionally, CraftMetaSkull also had the same issue with a null GameProfile, so this also ensures it doesn't break. The whole CraftPlayerProfile class is not null-safe, it requires a GameProfile that isn't null so we add a Validation on the constructor, that way it is easier to catch this kind of issue in the future.
This commit is contained in:
@@ -48,7 +48,7 @@ index 20588598386a4f479e6a58b294149bed789c63ce..ecc32c2fb1e8e1ac03074102b982adb4
|
||||
public BlockFace getRotation() {
|
||||
BlockData blockData = getBlockData();
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
||||
index 52c8d31590ea8e355395fa95cf690cc3770f5f71..2a3c86b0cbce0c37ebd8cace138c72c99f7455ea 100644
|
||||
index 35eda0a03cfec244103cfe4b998f9d2b9322fe69..109edb76618025651d05689d9db52248220550ca 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaSkull.java
|
||||
@@ -3,6 +3,8 @@ package org.bukkit.craftbukkit.inventory;
|
||||
@@ -68,7 +68,7 @@ index 52c8d31590ea8e355395fa95cf690cc3770f5f71..2a3c86b0cbce0c37ebd8cace138c72c9
|
||||
@DelegateDeserialization(SerializableMeta.class)
|
||||
class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||
|
||||
@@ -138,6 +141,19 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||
@@ -140,6 +143,19 @@ class CraftMetaSkull extends CraftMetaItem implements SkullMeta {
|
||||
return hasOwner() ? profile.getName() : null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user