diff --git a/bukkit/src/main/resources/config.yml b/bukkit/src/main/resources/config.yml index 6508007e0..b07a59f33 100644 --- a/bukkit/src/main/resources/config.yml +++ b/bukkit/src/main/resources/config.yml @@ -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 diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeConfig.java b/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeConfig.java index c13440d0f..05d876d26 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeConfig.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeConfig.java @@ -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) new ArrayList<>(section.getKeys())).orElse(def); } @Override diff --git a/bungee/src/main/resources/config.yml b/bungee/src/main/resources/config.yml index dd8d7925a..de67ffeeb 100644 --- a/bungee/src/main/resources/config.yml +++ b/bungee/src/main/resources/config.yml @@ -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 diff --git a/common/src/main/java/me/lucko/luckperms/common/dependencies/DependencyManager.java b/common/src/main/java/me/lucko/luckperms/common/dependencies/DependencyManager.java index 974ebbd95..c9c72ab29 100644 --- a/common/src/main/java/me/lucko/luckperms/common/dependencies/DependencyManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/dependencies/DependencyManager.java @@ -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)) diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/StorageFactory.java b/common/src/main/java/me/lucko/luckperms/common/storage/StorageFactory.java index cc9bbf70a..39b8bc795 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/StorageFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/StorageFactory.java @@ -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: diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/StorageType.java b/common/src/main/java/me/lucko/luckperms/common/storage/StorageType.java index 057c38e8f..9463dd80a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/StorageType.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/StorageType.java @@ -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"); diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/backing/sqlprovider/MySQLProvider.java b/common/src/main/java/me/lucko/luckperms/common/storage/backing/sqlprovider/MySQLProvider.java index 63a5cf3d6..811718d78 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/backing/sqlprovider/MySQLProvider.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/backing/sqlprovider/MySQLProvider.java @@ -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"); diff --git a/common/src/main/java/me/lucko/luckperms/common/utils/HikariSupplier.java b/common/src/main/java/me/lucko/luckperms/common/utils/HikariSupplier.java index ea73e00a9..c0dca01ef 100644 --- a/common/src/main/java/me/lucko/luckperms/common/utils/HikariSupplier.java +++ b/common/src/main/java/me/lucko/luckperms/common/utils/HikariSupplier.java @@ -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); diff --git a/common/src/main/resources/lp-schema-mariadb.sql b/common/src/main/resources/lp-schema-mariadb.sql new file mode 100644 index 000000000..0d5088e9d --- /dev/null +++ b/common/src/main/resources/lp-schema-mariadb.sql @@ -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; \ No newline at end of file diff --git a/sponge/src/main/resources/luckperms.conf b/sponge/src/main/resources/luckperms.conf index 996f2b6fe..e6172e28d 100644 --- a/sponge/src/main/resources/luckperms.conf +++ b/sponge/src/main/resources/luckperms.conf @@ -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