###Creates new scoreboards
scoreboard objectives add nitDragonology dummy
scoreboard objectives add nitDragonState dummy

###Create the tower lobby###
place template nitref:city/lobby ~-2 ~-5 ~-7

###Places the siteplanner on top###
place template nitref:siteplanner ~5 ~4 ~1

###Remove the charter###
clear @p written_book{title:"Refugee Plans"}

###Assigns the city's ID###
execute store result score @s nitID run data get entity @s UUID[0]
scoreboard players operation @e[tag=nitChorusStor,limit=1,sort=nearest] nitID = @s nitID
scoreboard players operation @e[tag=nitEndstoneStor,limit=1,sort=nearest] nitID = @s nitID

###Summons the town planner###
execute as @e[tag=nitCityPlanner] at @s run summon villager ~ ~ ~ {VillagerData:{profession:cartographer,level:4,type:snow},Invulnerable:1,PersistenceRequired:1,NoAI:1,Silent:1,CustomName:'{"text":"City Planner"}',Offers:{Recipes:[{buy:{id:"minecraft:feather",Count:1},sell:{id:"minecraft:written_book",Count:1},maxUses:9999999}]},Tags:[nitEndizen,nitEntity,nitRCP,smithed.entity,smithed.strict]}
scoreboard players operation @e[tag=nitRCP,limit=1,sort=nearest] nitID = @s nitID
execute as @e[tag=nitCityPlanner,limit=1,sort=nearest] at @s run summon enderman ~ ~ ~ {CustomName:'{"text":"City Planner"}',Invulnerable:1b,NoAI:1b,PersistenceRequired:1b,Tags:[nitEnderCP,smithed.entity,smithed.strict]}
execute as @e[tag=nitRCP,limit=1,sort=nearest] at @s run tp @e[tag=nitEnderCP,limit=1,sort=nearest] @s
effect give @e[tag=nitRCP,limit=1,sort=nearest] minecraft:invisibility 999999 0 true
function nitk:debug/update_all
kill @e[tag=nitCityPlanner]

###Creates the team to start having Endermen be friendly toward the player###
tellraw @s [{"text":"[۩]","color":"green","bold":true},{"text":": ","color":"white","bold":false},{"text":"You have successfully started an End City for the Enderman refugees!","color":"white","bold":false}]
team add nitFriendEnd {"text": "Endermen"}
team modify nitFriendEnd friendlyFire false
team join nitFriendEnd @a[distance=..20]