How to detect color-named armor? (1.15.2) [duplicate]

I am working on a command block contraption on my server that involves armor giving you certain potion effects.

/execute if entity @p[nbt={Inventory[{Slot:100b,id:"minecraft:leather_boots",tag:{display:{Name:"{\"text\":\"Frog Boots\"}"}}}]}] run effect give @s jump_boost 1 1 true

However, it only works if the boots are named in an anvil. How would I write the command if I wanted to test if the player was wearing boots named "Frog Boots" in bold and green text?


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

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.