This commit is contained in:
nossr50 2021-04-18 17:52:45 -07:00
parent 317f966f73
commit aa562a4710
3 changed files with 20 additions and 9 deletions

View File

@ -1,4 +1,7 @@
Version 2.1.194
Fixed an XP exploit
Updated SQL to not throw errors if upgrades.yml was reset for any reason
Updated SQL to use the newest driver path (and fall back to the old one if the new one doesn't exist on the server)
Locale override files are now named locale_override.properties (converted automatically/generated automatically)
Existing in use locale override files will be renamed to locale_override.properties and have some useful text put in them
mcMMO will now generate a locale override file with some detailed instructions if one doesn't exist (will be found in /plugins/mcMMO/locales/locale_override.properties)

View File

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>2.1.194-SNAPSHOT</version>
<version>2.1.194</version>
<name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url>
<scm>

View File

@ -31,6 +31,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
public static final String UUID_VARCHAR = "VARCHAR(36)";
public static final String USER_VARCHAR = "VARCHAR(40)";
public static final int CHILD_SKILLS_SIZE = 2;
public static final String LEGACY_DRIVER_PATH = "com.mysql.jdbc.Driver";
private final String tablePrefix = mcMMO.p.getGeneralConfig().getMySQLTablePrefix();
private final Map<UUID, Integer> cachedUserIDs = new HashMap<>();
@ -44,6 +45,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
private final ReentrantLock massUpdateLock = new ReentrantLock();
private final String CHARSET_SQL = "utf8mb4"; //This is compliant with UTF-8 while "utf8" is not, confusing but this is how it is.
private String driverPath = "com.mysql.cj.jdbc.Driver"; //modern driver
protected SQLDatabaseManager() {
String connectionString = "jdbc:mysql://" + mcMMO.p.getGeneralConfig().getMySQLServerName()
@ -60,10 +62,16 @@ public final class SQLDatabaseManager implements DatabaseManager {
try {
// Force driver to load if not yet loaded
Class.forName("com.mysql.jdbc.Driver");
}
catch (ClassNotFoundException e) {
Class.forName(driverPath);
} catch (ClassNotFoundException e) {
try {
driverPath = LEGACY_DRIVER_PATH; //fall on deprecated path if new path isn't found
Class.forName(driverPath);
} catch (ClassNotFoundException ex) {
e.printStackTrace();
ex.printStackTrace();
mcMMO.p.getLogger().severe("Neither driver found");
}
return;
//throw e; // aborts onEnable() Riking if you want to do this, fully implement it.
}
@ -71,7 +79,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
debug = mcMMO.p.getGeneralConfig().getMySQLDebug();
PoolProperties poolProperties = new PoolProperties();
poolProperties.setDriverClassName("com.mysql.jdbc.Driver");
poolProperties.setDriverClassName(driverPath);
poolProperties.setUrl(connectionString);
poolProperties.setUsername(mcMMO.p.getGeneralConfig().getMySQLUserName());
poolProperties.setPassword(mcMMO.p.getGeneralConfig().getMySQLUserPassword());
@ -86,7 +94,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
poolProperties.setValidationInterval(30000);
miscPool = new DataSource(poolProperties);
poolProperties = new PoolProperties();
poolProperties.setDriverClassName("com.mysql.jdbc.Driver");
poolProperties.setDriverClassName(driverPath);
poolProperties.setUrl(connectionString);
poolProperties.setUsername(mcMMO.p.getGeneralConfig().getMySQLUserName());
poolProperties.setPassword(mcMMO.p.getGeneralConfig().getMySQLUserPassword());
@ -101,7 +109,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
poolProperties.setValidationInterval(30000);
savePool = new DataSource(poolProperties);
poolProperties = new PoolProperties();
poolProperties.setDriverClassName("com.mysql.jdbc.Driver");
poolProperties.setDriverClassName(driverPath);
poolProperties.setUrl(connectionString);
poolProperties.setUsername(mcMMO.p.getGeneralConfig().getMySQLUserName());
poolProperties.setPassword(mcMMO.p.getGeneralConfig().getMySQLUserPassword());
@ -1018,7 +1026,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
break;
case ADD_SQL_INDEXES:
checkUpgradeAddSQLIndexes(statement);
// checkUpgradeAddSQLIndexes(statement);
break;
case ADD_MOB_HEALTHBARS: