Oh! So that's why it's never used here

This commit is contained in:
riking 2013-10-08 20:47:20 -07:00 committed by TfT_02
parent b3cf9bf839
commit 766f1f4127

View File

@ -10,7 +10,7 @@ public class DatabaseManagerFactory {
public static DatabaseManager getDatabaseManager() { public static DatabaseManager getDatabaseManager() {
if (customManager != null) { if (customManager != null) {
try { try {
return createCustomDatabaseManager(customManager); return createDefaultCustomDatabaseManager();
} }
catch (Exception e) { catch (Exception e) {
mcMMO.p.debug("Could not create custom database manager"); mcMMO.p.debug("Could not create custom database manager");
@ -29,15 +29,16 @@ public class DatabaseManagerFactory {
/** /**
* Sets the custom DatabaseManager class for mcMMO to use. This should be * Sets the custom DatabaseManager class for mcMMO to use. This should be
* called prior to mcMMO enabling. * called prior to mcMMO enabling.
* <p> * <p/>
* The provided class must have an empty constructor, which is the one * The provided class must have an empty constructor, which is the one
* that will be used. * that will be used.
* <p> * <p/>
* This method is intended for API use, but it should not be considered * This method is intended for API use, but it should not be considered
* stable. This method is subject to change and/or removal in future * stable. This method is subject to change and/or removal in future
* versions. * versions.
* *
* @param clazz the DatabaseManager class to use * @param clazz the DatabaseManager class to use
*
* @throws IllegalArgumentException if the provided class does not have * @throws IllegalArgumentException if the provided class does not have
* an empty constructor * an empty constructor
*/ */
@ -63,13 +64,24 @@ public class DatabaseManagerFactory {
case SQL: case SQL:
return new SQLDatabaseManager(); return new SQLDatabaseManager();
case CUSTOM:
try {
return createDefaultCustomDatabaseManager();
}
catch (Throwable e) {
e.printStackTrace();
}
default: default:
return null; return null;
} }
} }
//TODO: Why is clazz never used here? public static DatabaseManager createDefaultCustomDatabaseManager() throws Throwable {
return customManager.getConstructor((Class<?>) null).newInstance((Object[]) null);
}
public static DatabaseManager createCustomDatabaseManager(Class<? extends DatabaseManager> clazz) throws Throwable { public static DatabaseManager createCustomDatabaseManager(Class<? extends DatabaseManager> clazz) throws Throwable {
return customManager.getConstructor((Class<?>) clazz).newInstance((Object[]) null); return clazz.getConstructor((Class<?>) null).newInstance((Object[]) null);
} }
} }