manually disable pvp using EntityAttackByEntityEvent cancel this if pvp is disabled for the player being attacked or the player who is attacking. you can also use Essentials api if you wish
sessp Create a HashMap with the player's name/UUID and a boolean. On EntityDamageByEntityEvent, check the boolean for the specific player and cancel it. To set the boolean, use PlayerInteractEvent.
sessp In code? Nah, no one is going to spoonfeed any code. Everything you need to know is on the Javadocs, man.