Player.equip() not working?

What am I doing wrong?

ItemStack helmet = ItemStack.builder()
           .itemType(ItemTypes.IRON_HELMET)
           .add(Keys.UNBREAKABLE, true)
           .build();
p.equip(EquipmentTypes.HEADWEAR, helmet);

To be honest. Didnt know that exists. Ive always gone into the inventory and set it directly.

Ask if you want to know that way (which works)

Yes please. Thank you.

Player player;
ItemStack stack;
Optional<Slot> opSlot = inventory.getEquipment().getSlot(EquipmentTypes.HEADWEAR);
if(!opSlot.isPresent()){
    //something went wrong 
    return;
}
opSlot.get().set(stack);

That works with latest 1.12 build - code looks perfectly fine.