switch SQL from latin1 to utf8mb4

This commit is contained in:
nossr50 2021-03-09 13:56:03 -08:00
parent 4402484d47
commit f4976e5ecb
3 changed files with 11 additions and 6 deletions

View File

@ -1,3 +1,6 @@
Version 2.1.180
mcMMO now uses UTF-8 compliant encoding for SQL databases (utf8mb4)
Version 2.1.179 Version 2.1.179
Fixed a bug for FlatFile databases where some players with changed nicknames would have their levels not loaded upon login (possibly wiping their data) Fixed a bug for FlatFile databases where some players with changed nicknames would have their levels not loaded upon login (possibly wiping their data)

View File

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

View File

@ -38,6 +38,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
private final ReentrantLock massUpdateLock = new ReentrantLock(); private final ReentrantLock massUpdateLock = new ReentrantLock();
private final String ENCODING = "utf8mb4"; //This is compliant with UTF-8 while "utf8" is not, confusing but this is how it is.
protected SQLDatabaseManager() { protected SQLDatabaseManager() {
String connectionString = "jdbc:mysql://" + Config.getInstance().getMySQLServerName() String connectionString = "jdbc:mysql://" + Config.getInstance().getMySQLServerName()
+ ":" + Config.getInstance().getMySQLServerPort() + "/" + Config.getInstance().getMySQLDatabaseName(); + ":" + Config.getInstance().getMySQLServerPort() + "/" + Config.getInstance().getMySQLDatabaseName();
@ -814,7 +816,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ "`lastlogin` int(32) unsigned NOT NULL," + "`lastlogin` int(32) unsigned NOT NULL,"
+ "PRIMARY KEY (`id`)," + "PRIMARY KEY (`id`),"
+ "INDEX(`user`(20) ASC)," + "INDEX(`user`(20) ASC),"
+ "UNIQUE KEY `uuid` (`uuid`)) DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;"); + "UNIQUE KEY `uuid` (`uuid`)) DEFAULT CHARSET=" + ENCODING + " AUTO_INCREMENT=1;");
tryClose(createStatement); tryClose(createStatement);
} }
tryClose(resultSet); tryClose(resultSet);
@ -828,7 +830,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ "`mobhealthbar` varchar(50) NOT NULL DEFAULT '" + Config.getInstance().getMobHealthbarDefault() + "'," + "`mobhealthbar` varchar(50) NOT NULL DEFAULT '" + Config.getInstance().getMobHealthbarDefault() + "',"
+ "`scoreboardtips` int(10) NOT NULL DEFAULT '0'," + "`scoreboardtips` int(10) NOT NULL DEFAULT '0',"
+ "PRIMARY KEY (`user_id`)) " + "PRIMARY KEY (`user_id`)) "
+ "DEFAULT CHARSET=latin1;"); + "DEFAULT CHARSET=" + ENCODING + ";");
tryClose(createStatement); tryClose(createStatement);
} }
tryClose(resultSet); tryClose(resultSet);
@ -853,7 +855,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ "`blast_mining` int(32) unsigned NOT NULL DEFAULT '0'," + "`blast_mining` int(32) unsigned NOT NULL DEFAULT '0',"
+ "`chimaera_wing` int(32) unsigned NOT NULL DEFAULT '0'," + "`chimaera_wing` int(32) unsigned NOT NULL DEFAULT '0',"
+ "PRIMARY KEY (`user_id`)) " + "PRIMARY KEY (`user_id`)) "
+ "DEFAULT CHARSET=latin1;"); + "DEFAULT CHARSET=" + ENCODING + ";");
tryClose(createStatement); tryClose(createStatement);
} }
tryClose(resultSet); tryClose(resultSet);
@ -881,7 +883,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ "`alchemy` int(10) unsigned NOT NULL DEFAULT "+startingLevel+"," + "`alchemy` int(10) unsigned NOT NULL DEFAULT "+startingLevel+","
+ "`total` int(10) unsigned NOT NULL DEFAULT "+totalLevel+"," + "`total` int(10) unsigned NOT NULL DEFAULT "+totalLevel+","
+ "PRIMARY KEY (`user_id`)) " + "PRIMARY KEY (`user_id`)) "
+ "DEFAULT CHARSET=latin1;"); + "DEFAULT CHARSET=" + ENCODING + ";");
tryClose(createStatement); tryClose(createStatement);
} }
tryClose(resultSet); tryClose(resultSet);
@ -906,7 +908,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ "`fishing` int(10) unsigned NOT NULL DEFAULT '0'," + "`fishing` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`alchemy` int(10) unsigned NOT NULL DEFAULT '0'," + "`alchemy` int(10) unsigned NOT NULL DEFAULT '0',"
+ "PRIMARY KEY (`user_id`)) " + "PRIMARY KEY (`user_id`)) "
+ "DEFAULT CHARSET=latin1;"); + "DEFAULT CHARSET=" + ENCODING + ";");
tryClose(createStatement); tryClose(createStatement);
} }
tryClose(resultSet); tryClose(resultSet);