mcMMO-Dev/mcMMO — pull request #1217 by riking (2013-06-23 19:02:18+00:00)
Title: DatabaseManager changes

### Problem
The PlayerProfile constructor makes a call to the database, which returns a magic-indexed ArrayList, which it then parses into numbers and puts into its fields. This is stupid - instead the constructor should provide all the info the PlayerProfile needs to construct, and without magic numbers.
Other plugins cannot provide mcMMO with a custom DatabaseManager.
`/mmoupdate` only supports Flatfile -> SQL.
FlatfileDatabase is inefficent in its purge methods.

### What this code does
- All code calling `new PlayerProfile(...)` is replaced with `mcMMO.getDatabaseManager().loadPlayerProfile(...)`, which returns a constructed PlayerProfile. The existing behavior of the second boolean parameter is preserved. *[This solves the core problem behind `/mmoupdate`.]*
- DatabaseManagerFactory has additional code to support custom DatabaseManager implementations. Any plugin providing a custom DatabaseManager must specify mcMMO as a dependency and give the factory its information `onLoad()`.
- DatabaseManagerFactory includes code to create a new SQLDatabaseManager and FlatfileDatabaseManager instance, which is required for `/mmoupdate`.
- DatabaseManagers are basically required to harbor the `/mmoupdate` implementation via `convertUsers(DatabaseManager destination)`. This enables them to be more efficent in the way they do it.
- FlatfileDatabase locks its file on access to prevent data loss when people are saved while the purge is running.
- FlatfileDatabase reads its file only **once** per purge, instead of purgedUsers times.