[SPIGOT-7791] Skull BlockState causes NullPointerException Created: 22/Jun/24  Updated: 25/Dec/24  Resolved: 22/Jun/24

Status: Resolved
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Simon Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Environment:

java version "21.0.3" 2024-04-16 LTS
Java(TM) SE Runtime Environment (build 21.0.3+7-LTS-152)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.3+7-LTS-152, mixed mode, sharing)

Windows 10

Output of /pl:

Plugins (1): TestPlugin


Attachments: Text File exception.log    
Version: This server is running CraftBukkit version 4231-Spigot-1aabe50-5e46f1c (MC: 1.21) (Implementing API version 1.21-R0.1-SNAPSHOT)
Plugin: TestPlugin
Guidelines Read: Yes

 Description   

If you set the type of a block to Material.PLAYER_HEAD a Nullpointer will occour.
The exception also occoures if you use setOwnerProfile(null) on Skull then the CraftSkull will set the internal Profile to null but the constructor of ResolvableProfile requires a non null GameProfile.

How to reproduce:

@EventHandler
public void on(PlayerInteractEvent e) {
    if (e.getHand() != EquipmentSlot.HAND) return;

    Block block = e.getClickedBlock();
    block.setType(Material.PLAYER_HEAD);
    block.getState().setType(Material.PLAYER_HEAD);
    //optional. The NPE can be forced this way
    //But it also shows without this line
    //((Skull) block.getState()).setOwnerProfile(null);
    block.getState().update(true);
}

 

The topic came up after this thread:
https://www.spigotmc.org/threads/gameprofile-is-null.652027/



 Comments   
Comment by Doc [ 21/Jul/24 ]

Timelordm1 The issue you comment its not related to this issue, the class GameProfile from mojang require the UUID and the NAME you are passing a null causing the exception.

Comment by MjdTime [ 21/Jul/24 ]

Hello, I have a similar problem in one of the plugins I use. sorry not sure if this is related or if this is the correct place.

final ItemStack myHead = new ItemStack(Material.PLAYER_HEAD, headAmount);         
SkullMeta headMeta = (SkullMeta) myHead.getItemMeta();
assert headMeta != null;
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
profile.getProperties().put("textures", new Property("textures", textureValue)); 

Caused by: java.lang.NullPointerException: Profile name must not be nullat java.base/java.util.Objects.requireNonNull(Objects.java:259) ~[?:?]

at com mojang.authlib.GameProfile.<init>(GameProfile.java:31)

 

Generated at Sat Dec 13 15:22:29 UTC 2025 using Jira 10.3.13#10030013-sha1:56dd970ae30ebfeda3a697d25be1f6388b68a422.