advancement revoke @s only pctf:rightclick_item
execute if score @s item_cooldown matches 1.. run return run function pctf:logic/items/on_cooldown 
execute if items entity @s weapon.mainhand *[custom_data~{damage:1b}] if score @s spell_cooldown1 matches 1.. run return 0
execute if items entity @s weapon.mainhand *[custom_data~{defence:1b}] if score @s spell_cooldown2 matches 1.. run return 0
execute if items entity @s weapon.mainhand *[custom_data~{utility:1b}] if score @s spell_cooldown3 matches 1.. run return 0
execute unless predicate pctf:offhand run return run tellraw @s {"text":"Clear your offhand item to use this!","color":"red"}

execute if items entity @s weapon.mainhand minecraft:firework_star[custom_data={wool_bomb:1b}] at @s run function pctf:logic/items/wool_bomb/summon
execute if items entity @s weapon.mainhand minecraft:firework_star[custom_data={smoke_bomb:1b}] at @s run function pctf:logic/items/smoke_bomb/summon
execute if items entity @s weapon.mainhand minecraft:tripwire_hook[custom_data={trap_kit:1b}] at @s run function pctf:logic/items/trap_kit/summon
execute if items entity @s weapon.mainhand minecraft:feather[custom_data={launch_feather:1b}] at @s run function pctf:logic/items/launch_feather/activate
execute if items entity @s weapon.mainhand minecraft:fire_charge[custom_data={flamethrower:1b}] at @s run function pctf:logic/items/flamethrower/summon
execute if items entity @s weapon.mainhand minecraft:player_head[custom_data~{lucky_block:1b}] at @s run function pctf:logic/items/lucky_block/check
execute if items entity @s weapon.mainhand minecraft:netherite_hoe[custom_data={minigun:1b}] at @s run function pctf:logic/items/minigun/summon
execute if items entity @s weapon.mainhand minecraft:diamond_hoe[custom_data={railgun:1b}] at @s run function pctf:logic/items/railgun/summon

execute if items entity @s weapon.mainhand *[custom_data~{scroll:1b}] at @s run function pctf:logic/items/scrolls/check

scoreboard players set @s leeway 5