Possession Trap

Necromancy
Level: Sorcerer */Wizard * 5, Warlock * 5
Components: V, S, F (a gem or crystal worth at least 500 gp)
Casting Time: 1 Standard Action
Range: personal
Target: you
Duration: 24 hours or until activated (see text 1 round/level
Saving Throw: -
Spell Resistance: -
  You place a protective ward over your spirit that ensnares creatures attempting to possess you. Should a creature attempt to possess you (such as via magic jar or a similar effect) while you are under the effects of possession trap, that creature must first succeed at a Will Save or its possession attempt is ruined and its spirit is shunted into this spell's focus gem. The trapped creature is contained within the focus gem for 1 round per Caster Level, acting as though it were trapped in a magic jar for the duration of this effect. This effect fails if you are not carrying the focus gem during the time of the possession attempt.
  If the possessor's Will Save is successful, you are affected by its possession attempt as normal, and may attempt a saving throw against this possession attempt if one is normally allowed. Regardless of whether the possessor fails or succeeds at its save against possession trap, you immediately become aware of the possession attempt and whether or not a creature is trapped in the focus gem. If the focus gem is destroyed while it contains a creature, the creature is immediately released.
  Once this spell is triggered, it offers no further protection, and a trapped creature can attempt to possess you again once it's free of the focus gem.