# wave counter

scoreboard players remove @a[scores={ammoTime=0..}] ammoTime 1

# actionbar wave
titleraw @a[scores={ammoTime=..0,nextWave=900..1000},tag=!downed,tag=!dead] actionbar {"rawtext": [{"text": "§4§lWave: §r§c"}, {"score":{"name": "@p","objective": "wave"}}]}
titleraw @a[tag=dead] actionbar {"rawtext": [{"text": "§4§lWave: §r§c"}, {"score":{"name": "@p","objective": "wave"}}, {"text": " || §lYou are spectating!"}]}

# actionbar wave display
titleraw @a[scores={ammoTime=..0,nextWave=900..1000,trial=1},tag=!downed,tag=!dead] actionbar {"rawtext": [{"text": "§4§lWave: §r§c"}, {"score":{"name": "@p","objective": "wave"}}, {"text": "\n§g§lActive Trial: §r§eComplete this wave without taking damage"}]}
execute @a[scores={ammoTime=..0,nextWave=900..1000,trial=2},tag=!downed,tag=!dead] ~~~ titleraw @s actionbar {"rawtext": [{"text": "§4§lWave: §r§c"}, {"score":{"name": "@s","objective": "wave"}}, {"text": "\n§g§lActive Trial: §r§eKnife 40 zombies\n§g§lProgress: §r§e"}, {"score":{"name": "@s","objective": "knife"}}]}
execute @a[scores={ammoTime=..0,nextWave=900..1000,trial=3},tag=!downed,tag=!dead] ~~~ titleraw @s actionbar {"rawtext": [{"text": "§4§lWave: §r§c"}, {"score":{"name": "@s","objective": "wave"}}, {"text": "\n§g§lActive Trial: §r§eKnife 80 zombies\n§g§lProgress: §r§e"}, {"score":{"name": "@s","objective": "knife"}}]}


execute @a[tag=!downed,tag=!dead,tag=power,scores={nextWave=900..1000}] ~~~ detect ~ ~-1 ~ amethyst_block 0 title @s actionbar §cThe wave must be over to teleport
execute @a[tag=!downed,tag=!dead,tag=power,scores={nextWave=..5}] ~~~ detect ~ ~-1 ~ amethyst_block 0 title @s actionbar §cThere must be atleast 5 seconds remaining to teleport
execute @a[tag=!downed,tag=!dead,tag=!power] ~~~ detect ~ ~-1 ~ amethyst_block 0 title @s actionbar §cThe power must be enabled to teleport