Make the standard MySQL driver the default again

This commit is contained in:
Luck 2017-04-06 11:30:17 +01:00
parent 5567b1dad8
commit 029dc9f8d9
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
10 changed files with 110 additions and 19 deletions

View File

@ -191,8 +191,12 @@ vault-debug: false
# +------------------------------------------------------------------------+ #
# Which storage method the plugin should use.
# Currently supported: mysql, postgresql, sqlite, h2, json, yaml, mongodb
# Fill out connection info below if you're using MySQL, PostgreSQL or MongoDB
#
# See: https://github.com/lucko/LuckPerms/wiki/Choosing-a-Storage-type
# Currently supported: mysql, mariadb, postgresql, sqlite, h2, json, yaml, mongodb
# Fill out connection info below if you're using MySQL, MariaDB, PostgreSQL or MongoDB
# If your MySQL server supports it, the "mariadb" option is preferred over "mysql".
storage-method: h2
# When using a file-based storage type, LuckPerms can monitor the data files for changes, and then schedule automatic

View File

@ -35,11 +35,11 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
@RequiredArgsConstructor
public class BungeeConfig extends AbstractConfiguration {
@ -104,7 +104,7 @@ public class BungeeConfig extends AbstractConfiguration {
return def;
}
return Optional.ofNullable(section.getKeys().stream().collect(Collectors.toList())).orElse(def);
return Optional.of((List<String>) new ArrayList<>(section.getKeys())).orElse(def);
}
@Override

View File

@ -140,8 +140,12 @@ meta-formatting:
# +------------------------------------------------------------------------+ #
# Which storage method the plugin should use.
# Currently supported: mysql, postgresql, sqlite, h2, json, yaml, mongodb
# Fill out connection info below if you're using MySQL, PostgreSQL or MongoDB
#
# See: https://github.com/lucko/LuckPerms/wiki/Choosing-a-Storage-type
# Currently supported: mysql, mariadb, postgresql, sqlite, h2, json, yaml, mongodb
# Fill out connection info below if you're using MySQL, MariaDB, PostgreSQL or MongoDB
# If your MySQL server supports it, the "mariadb" option is preferred over "mysql".
storage-method: h2
# When using a file-based storage type, LuckPerms can monitor the data files for changes, and then schedule automatic

View File

@ -60,8 +60,8 @@ public class DependencyManager {
.put(StorageType.JSON, ImmutableList.of())
.put(StorageType.YAML, ImmutableList.of())
.put(StorageType.MONGODB, ImmutableList.of(Dependency.MONGODB_DRIVER))
.put(StorageType.MYSQL, ImmutableList.of(Dependency.MARIADB_DRIVER, Dependency.SLF4J_API, Dependency.SLF4J_SIMPLE, Dependency.HIKARI))
.put(StorageType.MYSQL_LEGACY, ImmutableList.of(Dependency.MYSQL_DRIVER, Dependency.SLF4J_API, Dependency.SLF4J_SIMPLE, Dependency.HIKARI))
.put(StorageType.MARIADB, ImmutableList.of(Dependency.MARIADB_DRIVER, Dependency.SLF4J_API, Dependency.SLF4J_SIMPLE, Dependency.HIKARI))
.put(StorageType.MYSQL, ImmutableList.of(Dependency.MYSQL_DRIVER, Dependency.SLF4J_API, Dependency.SLF4J_SIMPLE, Dependency.HIKARI))
.put(StorageType.POSTGRESQL, ImmutableList.of(Dependency.POSTGRESQL_DRIVER, Dependency.SLF4J_API, Dependency.SLF4J_SIMPLE, Dependency.HIKARI))
.put(StorageType.SQLITE, ImmutableList.of(Dependency.SQLITE_DRIVER))
.put(StorageType.H2, ImmutableList.of(Dependency.H2_DRIVER))

View File

@ -122,16 +122,35 @@ public class StorageFactory {
private static AbstractBacking makeBacking(StorageType method, LuckPermsPlugin plugin) {
switch (method) {
case MARIADB:
return new SQLBacking(plugin, new MySQLProvider(
"MariaDB",
"org.mariadb.jdbc.MySQLDataSource",
plugin.getConfiguration().get(ConfigKeys.DATABASE_VALUES)),
plugin.getConfiguration().get(ConfigKeys.SQL_TABLE_PREFIX)
);
case MYSQL:
return new SQLBacking(plugin, new MySQLProvider("MySQL", "org.mariadb.jdbc.MySQLDataSource", plugin.getConfiguration().get(ConfigKeys.DATABASE_VALUES)), plugin.getConfiguration().get(ConfigKeys.SQL_TABLE_PREFIX));
case MYSQL_LEGACY:
return new SQLBacking(plugin, new MySQLProvider("MySQL-Legacy", "com.mysql.jdbc.jdbc2.optional.MysqlDataSource", plugin.getConfiguration().get(ConfigKeys.DATABASE_VALUES)), plugin.getConfiguration().get(ConfigKeys.SQL_TABLE_PREFIX));
return new SQLBacking(plugin, new MySQLProvider(
"MySQL",
"com.mysql.jdbc.jdbc2.optional.MysqlDataSource",
plugin.getConfiguration().get(ConfigKeys.DATABASE_VALUES)),
plugin.getConfiguration().get(ConfigKeys.SQL_TABLE_PREFIX)
);
case SQLITE:
return new SQLBacking(plugin, new SQLiteProvider(new File(plugin.getDataDirectory(), "luckperms-sqlite.db")), plugin.getConfiguration().get(ConfigKeys.SQL_TABLE_PREFIX));
return new SQLBacking(plugin, new SQLiteProvider(
new File(plugin.getDataDirectory(), "luckperms-sqlite.db")),
plugin.getConfiguration().get(ConfigKeys.SQL_TABLE_PREFIX)
);
case H2:
return new SQLBacking(plugin, new H2Provider(new File(plugin.getDataDirectory(), "luckperms-h2")), plugin.getConfiguration().get(ConfigKeys.SQL_TABLE_PREFIX));
return new SQLBacking(plugin, new H2Provider(
new File(plugin.getDataDirectory(), "luckperms-h2")),
plugin.getConfiguration().get(ConfigKeys.SQL_TABLE_PREFIX)
);
case POSTGRESQL:
return new SQLBacking(plugin, new PostgreSQLProvider(plugin.getConfiguration().get(ConfigKeys.DATABASE_VALUES)), plugin.getConfiguration().get(ConfigKeys.SQL_TABLE_PREFIX));
return new SQLBacking(plugin, new PostgreSQLProvider(
plugin.getConfiguration().get(ConfigKeys.DATABASE_VALUES)),
plugin.getConfiguration().get(ConfigKeys.SQL_TABLE_PREFIX)
);
case MONGODB:
return new MongoDBBacking(plugin, plugin.getConfiguration().get(ConfigKeys.DATABASE_VALUES));
case YAML:

View File

@ -33,8 +33,8 @@ public enum StorageType {
JSON("JSON", "json", "flatfile"),
YAML("YAML", "yaml", "yml"),
MONGODB("MongoDB", "mongodb"),
MARIADB("MariaDB", "mariadb"),
MYSQL("MySQL", "mysql"),
MYSQL_LEGACY("MySQL-Legacy", "mysql-legacy"),
POSTGRESQL("PostgreSQL", "postgresql"),
SQLITE("SQLite", "sqlite"),
H2("H2", "h2");

View File

@ -66,7 +66,7 @@ public class MySQLProvider extends SQLProvider {
config.setUsername(username);
config.setPassword(password);
if (getName().toLowerCase().endsWith("legacy")) {
if (!getName().toLowerCase().equals("mariadb")) {
// doesn't exist on the MariaDB driver
config.addDataSourceProperty("cachePrepStmts", "true");

View File

@ -43,7 +43,7 @@ public class HikariSupplier implements AutoCloseable {
hikari = new HikariDataSource();
hikari.setPoolName(poolName);
hikari.setMaximumPoolSize(2);
hikari.setDataSourceClassName("org.mariadb.jdbc.Driver");
hikari.setDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource");
hikari.addDataSourceProperty("serverName", address.split(":")[0]);
hikari.addDataSourceProperty("port", address.split(":")[1]);
hikari.addDataSourceProperty("databaseName", database);

View File

@ -0,0 +1,60 @@
-- LuckPerms MariaDB Schema
CREATE TABLE `{prefix}user_permissions` (
`id` INT AUTO_INCREMENT NOT NULL,
`uuid` VARCHAR(36) NOT NULL,
`permission` VARCHAR(200) NOT NULL,
`value` BOOL NOT NULL,
`server` VARCHAR(36) NOT NULL,
`world` VARCHAR(36) NOT NULL,
`expiry` INT(11) NOT NULL,
`contexts` VARCHAR(200) NOT NULL,
PRIMARY KEY (`id`)
) DEFAULT CHARSET = utf8;
CREATE INDEX `{prefix}user_permissions_uuid` ON `{prefix}user_permissions` (`uuid`);
CREATE INDEX `{prefix}user_permissions_permission` ON `{prefix}user_permissions` (`permission`);
CREATE TABLE `{prefix}group_permissions` (
`id` INT AUTO_INCREMENT NOT NULL,
`name` VARCHAR(36) NOT NULL,
`permission` VARCHAR(200) NOT NULL,
`value` BOOL NOT NULL,
`server` VARCHAR(36) NOT NULL,
`world` VARCHAR(36) NOT NULL,
`expiry` INT(11) NOT NULL,
`contexts` VARCHAR(200) NOT NULL,
PRIMARY KEY (`id`)
) DEFAULT CHARSET = utf8;
CREATE INDEX `{prefix}group_permissions_name` ON `{prefix}group_permissions` (`name`);
CREATE INDEX `{prefix}group_permissions_permission` ON `{prefix}group_permissions` (`permission`);
CREATE TABLE `{prefix}players` (
`uuid` VARCHAR(36) NOT NULL,
`username` VARCHAR(16) NOT NULL,
`primary_group` VARCHAR(36) NOT NULL,
PRIMARY KEY (`uuid`)
) DEFAULT CHARSET = utf8;
CREATE INDEX `{prefix}players_username` ON `{prefix}players` (`username`);
CREATE TABLE `{prefix}groups` (
`name` VARCHAR(36) NOT NULL,
PRIMARY KEY (`name`)
) DEFAULT CHARSET = utf8;
CREATE TABLE `{prefix}actions` (
`id` INT AUTO_INCREMENT NOT NULL,
`time` BIGINT NOT NULL,
`actor_uuid` VARCHAR(36) NOT NULL,
`actor_name` VARCHAR(16) NOT NULL,
`type` CHAR(1) NOT NULL,
`acted_uuid` VARCHAR(36) NOT NULL,
`acted_name` VARCHAR(36) NOT NULL,
`action` VARCHAR(256) NOT NULL,
PRIMARY KEY (`id`)
) DEFAULT CHARSET = utf8;
CREATE TABLE `{prefix}tracks` (
`name` VARCHAR(36) NOT NULL,
`groups` TEXT NOT NULL,
PRIMARY KEY (`name`)
) DEFAULT CHARSET = utf8;

View File

@ -147,8 +147,12 @@ meta-formatting {
# +------------------------------------------------------------------------+ #
# Which storage method the plugin should use.
# Currently supported: mysql, postgresql, sqlite, h2, json, yaml, mongodb
# Fill out connection info below if you're using MySQL, PostgreSQL or MongoDB
#
# See: https://github.com/lucko/LuckPerms/wiki/Choosing-a-Storage-type
# Currently supported: mysql, mariadb, postgresql, sqlite, h2, json, yaml, mongodb
# Fill out connection info below if you're using MySQL, MariaDB, PostgreSQL or MongoDB
# If your MySQL server supports it, the "mariadb" option is preferred over "mysql".
storage-method="h2"
# When using a file-based storage type, LuckPerms can monitor the data files for changes, and then schedule automatic