place template nitk:upgrades/town_hall ~-7 ~ ~-7

tp @e[tag=nitTownPlanner,limit=1,sort=nearest] ~ ~4 ~4
tp @e[tag=nitKTP,limit=1,sort=nearest] ~ ~3.5 ~4

execute as @e[tag=nitTownRep,limit=1,sort=nearest] at @s unless entity @e[type=villager,tag=nitKTR,distance=..2] run summon villager ~ ~ ~ {VillagerData:{profession:"librarian",level:4,type:"plains"},Invulnerable:1,PersistenceRequired:1,NoAI:1,CustomName:'{"text":"Town Representative"}',Offers:{Recipes:[{buy:{id:"minecraft:feather",Count:1},sell:{id:"minecraft:written_book",Count:1},maxUses:9999999},{buy:{id:"minecraft:paper",Count:1b,tag:{nitk_buildingPermit:1b,HideFlags:1,display:{Lore:['{"text":"The final ingredient","color":"gray","italic":false}','{"text":"in new town structures.","color":"gray","italic":false}'],Name:'{"text":"Building Permit","color":"blue","italic":false}'},Enchantments:[{id:"minecraft:protection",lvl:0}]}},buyB:{id:"minecraft:dirt",Count:64},sell:{id:"minecraft:dirt_path",Count:1b,tag:{nitk_road:1b,display:{Name:'{"text":"Dirt Roads","bold":true,"italic":false}'}}}},{buy:{id:"minecraft:paper",Count:1b,tag:{nitk_buildingPermit:1b,HideFlags:1,display:{Lore:['{"text":"The final ingredient","color":"gray","italic":false}','{"text":"in new town structures.","color":"gray","italic":false}'],Name:'{"text":"Building Permit","color":"blue","italic":false}'},Enchantments:[{id:"minecraft:protection",lvl:0}]}},buyB:{id:"minecraft:oak_log",Count:64},sell:{id:"minecraft:spruce_planks",Count:1b,tag:{nitk_road:2b,display:{Name:'{"text":"Wooden Roads","bold":true,"italic":false}'}}}},{buy:{id:"minecraft:paper",Count:1b,tag:{nitk_buildingPermit:1b,HideFlags:1,display:{Lore:['{"text":"The final ingredient","color":"gray","italic":false}','{"text":"in new town structures.","color":"gray","italic":false}'],Name:'{"text":"Building Permit","color":"blue","italic":false}'},Enchantments:[{id:"minecraft:protection",lvl:0}]}},buyB:{id:"minecraft:packed_mud",Count:64},sell:{id:"minecraft:mud_bricks",Count:1b,tag:{nitk_road:3b,display:{Name:'{"text":"Paved Roads","bold":true,"italic":false}'}}}},{buy:{id:"minecraft:paper",Count:1b,tag:{nitk_buildingPermit:1b,HideFlags:1,display:{Lore:['{"text":"The final ingredient","color":"gray","italic":false}','{"text":"in new town structures.","color":"gray","italic":false}'],Name:'{"text":"Building Permit","color":"blue","italic":false}'},Enchantments:[{id:"minecraft:protection",lvl:0}]}},buyB:{id:"minecraft:deepslate",Count:64},sell:{id:"minecraft:cobbled_deepslate",Count:1b,tag:{nitk_road:4b,display:{Name:'{"text":"Cobbled Roads","bold":true,"italic":false}'}}}}]},Tags:[nitCitizen,nitKTR,smithed.entity,smithed.strict,nitEntity]}
scoreboard players operation @e[tag=nitKTR,limit=1,sort=nearest] nitID = @s nitID
scoreboard players operation @e[tag=nitTownRep,limit=1,sort=nearest] nitID = @s nitID
function nitk:debug/update_all

###Cleanup###
function nitk:siteplanner/upgrades/cleanup