###Spams chat if command blocks are disabled###
tellraw @s[tag=nitCBDisabled] [{"text":"[۩New in Town]","color":"green","bold":true},{"text":": ","color":"white","bold":false},{"text":"Command blocks are disabled. Please enable command blocks to enjoy the settler's experience.","color":"white","bold":false}]

###Starts the settlement if the player used a Charter Book###
execute if entity @s[scores={nitContract=1}] run function nitk:contract_test
execute if entity @s[scores={nitContract=2}] run function nitco:contract_test
execute if entity @s[scores={nitContract=3}] run function nitref:contract_test

###Checks if there isn't an Ender Dragon and gives the appropriate advancement###
execute if entity @s[predicate=nitref:end_dimension,advancements={nitco:nitco/ach5.1=true,nitref:nitref/ach2.1=false}] if entity @e[type=ender_dragon] run advancement revoke @s[predicate=nitref:end_dimension,advancements={nitco:nitco/ach5.1=true}] only nitref:nitref/ach2.1 return-to-end
execute if entity @s[predicate=nitref:end_dimension,advancements={nitco:nitco/ach5.1=true,nitref:nitref/ach2.1=false}] unless block 0 50 0 air run advancement revoke @s[predicate=nitref:end_dimension,advancements={nitco:nitco/ach5.1=true}] only nitref:nitref/ach2.1 return-to-end
execute if entity @s[predicate=nitref:end_dimension,advancements={nitco:nitco/ach5.1=true,nitref:nitref/ach2.1=false}] unless entity @e[type=ender_dragon] unless block 0 50 0 air run advancement grant @s[predicate=nitref:end_dimension,advancements={nitco:nitco/ach5.1=true}] only nitref:nitref/ach2.1 dragon-killed

###Adds nearby Endermen to the team friendly to the player###
execute if entity @s[predicate=nitref:end_dimension,distance=..10] run team join nitFriendEnd @s[type=enderman]
execute if entity @s[predicate=nitref:end_dimension,distance=..10,team=nitFriendEnd] run data merge entity @s[type=enderman,team=nitFriendEnd] {Invulnerable:1b}