Minecraft wiki entry for Command_blocks_and_functions, associated text: Using pressure plates or tripwire, make areas (like a castle for instance) a different difficulty (in this instance peaceful). the doors could have tripwire hook to a command block that changes ones difficulty to peaceful, creating a sort of "Safe Haven". one could also do it the other way around, creating a more dangerous zone, such as arenas having the difficulty of hard, rather than normal or easy. Note that in multiplayer this will change the difficulty everywhere in the world, and thus may not be desirable.