Getting player skull block data

Is there a way to get a player skull block’s data, eg. the skin or the UUID of the skull owner?

For developers:

Skulls representing a player are marked with Keys.REPRESENTED_PLAYER and a backing GameProfile that contains (among other things) the UUID of the User - you should be able to get what you need from there.


My belief for this particular question is that you’re after this from a user perspective, so in that case:

Simply put, you can’t - at least on your own. You’ll need some type of plugin that allows you to see data about the item (or block) in question. It’s not particularly difficult to do (though for reasons beyond the scope of this question the plugin would need to specifically check for the necessary key), but I know of no plugin that has this type of functionality. Your best bet would be to try something that serializes an item to a config file and see what you end up with.

Oh haha I was actually going on it at a developer’s perspective. Just trying to make a simple plugin, but I’m not very well experienced with sponge so having difficulties finding the info I need for it. I don’t really understand the javadocs, nor do I know how to apply it :confused: . Do you perhaps have an example for how you would check if skull owner = SnowBlitzz when the skull is right clicked? I can only get this far lol

	public void onRightClick(InteractBlockEvent.Secondary.MainHand e, @First Player player) {
		HandType handType = e.getHandType();
		BlockSnapshot block = e.getTargetBlock();
		if(handType.equals(HandTypes.MAIN_HAND)) {
			if (block == BlockTypes.SKULL) {
						

			}
		}
	}
if (block.getState().getType() == BlockTypes.SKULL) {
    Optional<GameProfile> optProfile = block.get(Keys.REPRESENTED_PLAYER);
    if (optProfile.isPresent()) {
        UUID representedPlayer = optProfile.get().getUniqueId();
    }
}

I’ll leave you to determine how you want to use the given UUID to handle comparisons, but my suggestion would be to avoid using names.

Note that block == BlockTypes.SKULL will always be false. I’ve edited that section to get the actual BlockType from the representing BlockState, but I’d personally skip over the check entirely - if optProfile is present, then the block must be a human skull.

Also, probably best to have things like this in #plugins:plugin-development so it’s clear it’s a development question. :snake: