How do I execute for a player wearing armor with a colored name

Solution 1:

The NBT syntax for testing for an item with a certain name is exactly the same as the NBT syntax for giving a player an item with that name. Thus, if you give a player boots using the command:

/give <player> leather_boots{display:{Name:"{\"text\":\"Frog Boots\",\"color\":\"green\",\"bold\":true}"}}

(per my answer to Colored item names in Minecraft?), you check if the player is wearing those boots using the command:

/execute if entity @p[nbt={Inventory:[{Slot:100b,id:"minecraft:leather_boots",tag:{display:{Name:"{\"text\":\"Frog Boots\",\"color\":\"green\",\"bold\":true}"}}}]}] run ...

You can figure out the exact NBT name of an item by selecting it, and running the command:

/data get entity @s SelectedItem.tag.display.Name

Solution 2:

Answer from the OP, posted in the question body:


I found out you can test if the player is wearing dyed armor, so I’m doing that instead.