mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
Oh! So that's why it's never used here
This commit is contained in:
parent
b3cf9bf839
commit
766f1f4127
@ -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,17 +29,18 @@ 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
|
||||||
*/
|
*/
|
||||||
public static void setCustomDatabaseManagerClass(Class<? extends DatabaseManager> clazz) {
|
public static void setCustomDatabaseManagerClass(Class<? extends DatabaseManager> clazz) {
|
||||||
try {
|
try {
|
||||||
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user