use of com.palmergames.bukkit.towny.db.TownyFlatFileSource in project Towny by TownyAdvanced.
the class TownyUniverse method loadDatabase.
/**
* Loads the database into memory.
*
* @param loadDbType - load setting from the config.
* @return true when the database will load.
*/
private boolean loadDatabase(String loadDbType) {
long startTime = System.currentTimeMillis();
/*
* Select the datasource.
*/
switch(loadDbType.toLowerCase()) {
case "ff":
case "flatfile":
{
this.dataSource = new TownyFlatFileSource(towny, this);
break;
}
case "mysql":
{
this.dataSource = new TownySQLSource(towny, this);
break;
}
default:
{
throw new TownyInitException("Database: Database.yml unsupported load format: " + loadDbType, TownyInitException.TownyError.DATABASE_CONFIG);
}
}
/*
* Load the actual database.
*/
if (!dataSource.loadAll())
throw new TownyInitException("Database: Failed to load database.", TownyInitException.TownyError.DATABASE);
long time = System.currentTimeMillis() - startTime;
towny.getLogger().info("Database: Loaded in " + time + "ms.");
// TODO: remove this when we're using UUIDs directly in the database.
towny.getLogger().info("Database: " + TownySettings.getUUIDPercent() + " of residents have stored UUIDs.");
// Throw Event.
Bukkit.getPluginManager().callEvent(new TownyLoadedDatabaseEvent());
// Congratulations the Database loaded.
return true;
}
Aggregations