Player.equip() not working?

What am I doing wrong?

ItemStack helmet = ItemStack.builder()
           .add(Keys.UNBREAKABLE, true)
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);
    //something went wrong 

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