#checking spawns
tellraw @s {"text":"Checking spawn markers...","color":"dark_green"}
$execute unless entity @e[type=marker,tag=blue_spawn,scores={map_id=$(map_id)}] run return run tellraw @s {"text":"Missing blue_spawn for map $(map_id)!","color":"red"}
$execute unless entity @e[type=marker,tag=red_spawn,scores={map_id=$(map_id)}] run return run tellraw @s {"text":"Missing red_spawn for map $(map_id)!","color":"red"}

#checking flags
tellraw @s {"text":"Checking flag markers...","color":"dark_green"}
$execute unless entity @e[type=marker,tag=green_flag_location,scores={map_id=$(map_id)}] run return run tellraw @s {"text":"Missing green_flag_location for map $(map_id)!","color":"red"}
$execute unless entity @e[type=marker,tag=light_purple_flag_location,scores={map_id=$(map_id)}] run return run tellraw @s {"text":"Missing light_purple_flag_location for map $(map_id)!","color":"red"}
$execute unless entity @e[type=marker,tag=aqua_flag_location,scores={map_id=$(map_id)}] run return run tellraw @s {"text":"Missing aqua_flag_location for map $(map_id)!","color":"red"}
$execute unless entity @e[type=marker,tag=yellow_flag_location,scores={map_id=$(map_id)}] run return run tellraw @s {"text":"Missing yellow_flag_location for map $(map_id)!","color":"red"}

#checking flag dropoff
tellraw @s {"text":"Checking flag dropoff markers...","color":"dark_green"}
$execute unless entity @e[type=marker,tag=blue_flag_dropoff,scores={map_id=$(map_id)}] run return run tellraw @s {"text":"Missing blue_flag_dropoff for map $(map_id)!","color":"red"}
$execute unless entity @e[type=marker,tag=red_flag_dropoff,scores={map_id=$(map_id)}] run return run tellraw @s {"text":"Missing red_flag_dropoff for map $(map_id)!","color":"red"}

#checking death plane
tellraw @s {"text":"Checking death plane marker...","color":"dark_green"}
$execute unless entity @e[type=marker,tag=death_plane,scores={map_id=$(map_id)}] run return run tellraw @s {"text":"Missing death_plane for map $(map_id)!","color":"red"}

#checking lobby
tellraw @s {"text":"Checking lobby marker...","color":"dark_green"}
$execute unless entity @e[type=marker,tag=map_lobby,scores={map_id=$(map_id)}] run return run tellraw @s {"text":"Missing map_lobby for map $(map_id)!","color":"red"}

#checking shop
tellraw @s {"text":"Checking for 2 shop markers...","color":"dark_green"}
$execute store result score .num temp if entity @e[type=marker,tag=shop_location,scores={map_id=$(map_id)}]
$execute if score .num temp matches 3.. run return run tellraw @s {"text":"There must be ONLY 2 shop markers for map $(map_id)! You have 3+. Indicated by green sparkly particles","color":"red"}
$execute if score .num temp matches 1 run return run tellraw @s {"text":"There must be 2 shop markers for map $(map_id)! You only have 1. Indicated by green sparkly particles","color":"red"}
$execute if score .num temp matches 0 run return run tellraw @s {"text":"There must be 2 shop markers for map $(map_id)! You have none","color":"red"}

#checking center
tellraw @s {"text":"Checking center marker...","color":"dark_green"}
$execute unless entity @e[type=marker,tag=map_center,scores={map_id=$(map_id)}] run return run tellraw @s {"text":"Missing map_center for map $(map_id)!","color":"red"}

#success
$tellraw @s {"text":"Success! The map game$(map_id) has been successfully editted!","color":"green"}
$tag @e[tag=map_lobby,tag=not_active,scores={map_id=$(map_id)}] remove not_active

gamemode adventure @s
function pctf:tp/lobby

execute at @s run playsound minecraft:entity.player.levelup player @s ~ ~ ~ 0.5 0

tag @s remove edit_mode
tag @s[name=!phaic] remove dev