Command to spawn in-game Player head?

I want to spawn a player head in my custom Minecraft map I'm making, but the problem is, the username has to be defined to give the actual player's head:

/give @p minecraft:skull 1 3 {SkullOwner:"<playername>"}

But I want this to work for any player that plays the map. Is there a way to build a command to do this?


Solution 1:

I wrote a script to do it...

This is written in Python and works on vanilla minecraft (even snapshots)

I currently give players a purple_shulker_box the first time they are seen by the server

https://github.com/Veritas83/Minecraft.SNAPSHOT.Commands.Mod/blob/master/commands.by.YT_Veritas0923.py

Line 1150-1153

if freeshulkerbox == True:
    cmdin = "give " + player + " purple_shulker_box 1\n"
    print "[" + get24hrtime() + "] [Script thread/EXEC]: " + cmdin,
    p.stdin.write(cmdin)

Change to:

if freeshulkerbox == True:
    cmdin = "give " + player + " minecraft:skull 1 3 {SkullOwner:" + player + "}\n"
    print "[" + get24hrtime() + "] [Script thread/EXEC]: " + cmdin,
    p.stdin.write(cmdin)

I think this will accomplish what you are asking.

Update:

I just tested this, and it does indeed work. :)

enter image description here