Added compatibility with Vanilla 2.0

I refactored the plugin a bit, increasing the separation of concern, and added compatibility with Vanilla 2.0 event model.

Changes have been tested on:  
- Vanilla 2.0.18.2
- Vanilla 2.0.18.4
- Vanilla 2.0.18.8
- Vanilla 2.1b1