

This datapack requires Guard villager mod, also if you want villagers to be able to follow you with this datapack, disable followHero option in config of the mod
Recruit a villager
You can now pay an emerald to the guard and change it's armor/weaponary, make him defend you.
This is a very simple datapack, you can modify it if you want
In Progress datapack for capturing/defending the villages for many teams.