Partly the code of the current villagedefender plugin