mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-28 05:35:26 +01:00
Make the standard MySQL driver the default again
This commit is contained in:
parent
5567b1dad8
commit
029dc9f8d9
@ -191,8 +191,12 @@ vault-debug: false
|
|||||||
# +------------------------------------------------------------------------+ #
|
# +------------------------------------------------------------------------+ #
|
||||||
|
|
||||||
# Which storage method the plugin should use.
|
# 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
|
storage-method: h2
|
||||||
|
|
||||||
# When using a file-based storage type, LuckPerms can monitor the data files for changes, and then schedule automatic
|
# When using a file-based storage type, LuckPerms can monitor the data files for changes, and then schedule automatic
|
||||||
|
@ -35,11 +35,11 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class BungeeConfig extends AbstractConfiguration {
|
public class BungeeConfig extends AbstractConfiguration {
|
||||||
@ -104,7 +104,7 @@ public class BungeeConfig extends AbstractConfiguration {
|
|||||||
return def;
|
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
|
@Override
|
||||||
|
@ -140,8 +140,12 @@ meta-formatting:
|
|||||||
# +------------------------------------------------------------------------+ #
|
# +------------------------------------------------------------------------+ #
|
||||||
|
|
||||||
# Which storage method the plugin should use.
|
# 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
|
storage-method: h2
|
||||||
|
|
||||||
# When using a file-based storage type, LuckPerms can monitor the data files for changes, and then schedule automatic
|
# When using a file-based storage type, LuckPerms can monitor the data files for changes, and then schedule automatic
|
||||||
|
@ -60,8 +60,8 @@ public class DependencyManager {
|
|||||||
.put(StorageType.JSON, ImmutableList.of())
|
.put(StorageType.JSON, ImmutableList.of())
|
||||||
.put(StorageType.YAML, ImmutableList.of())
|
.put(StorageType.YAML, ImmutableList.of())
|
||||||
.put(StorageType.MONGODB, ImmutableList.of(Dependency.MONGODB_DRIVER))
|
.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.MARIADB, 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.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.POSTGRESQL, ImmutableList.of(Dependency.POSTGRESQL_DRIVER, Dependency.SLF4J_API, Dependency.SLF4J_SIMPLE, Dependency.HIKARI))
|
||||||
.put(StorageType.SQLITE, ImmutableList.of(Dependency.SQLITE_DRIVER))
|
.put(StorageType.SQLITE, ImmutableList.of(Dependency.SQLITE_DRIVER))
|
||||||
.put(StorageType.H2, ImmutableList.of(Dependency.H2_DRIVER))
|
.put(StorageType.H2, ImmutableList.of(Dependency.H2_DRIVER))
|
||||||
|
@ -122,16 +122,35 @@ public class StorageFactory {
|
|||||||
|
|
||||||
private static AbstractBacking makeBacking(StorageType method, LuckPermsPlugin plugin) {
|
private static AbstractBacking makeBacking(StorageType method, LuckPermsPlugin plugin) {
|
||||||
switch (method) {
|
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:
|
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));
|
return new SQLBacking(plugin, new MySQLProvider(
|
||||||
case MYSQL_LEGACY:
|
"MySQL",
|
||||||
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));
|
"com.mysql.jdbc.jdbc2.optional.MysqlDataSource",
|
||||||
|
plugin.getConfiguration().get(ConfigKeys.DATABASE_VALUES)),
|
||||||
|
plugin.getConfiguration().get(ConfigKeys.SQL_TABLE_PREFIX)
|
||||||
|
);
|
||||||
case SQLITE:
|
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:
|
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:
|
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:
|
case MONGODB:
|
||||||
return new MongoDBBacking(plugin, plugin.getConfiguration().get(ConfigKeys.DATABASE_VALUES));
|
return new MongoDBBacking(plugin, plugin.getConfiguration().get(ConfigKeys.DATABASE_VALUES));
|
||||||
case YAML:
|
case YAML:
|
||||||
|
@ -33,8 +33,8 @@ public enum StorageType {
|
|||||||
JSON("JSON", "json", "flatfile"),
|
JSON("JSON", "json", "flatfile"),
|
||||||
YAML("YAML", "yaml", "yml"),
|
YAML("YAML", "yaml", "yml"),
|
||||||
MONGODB("MongoDB", "mongodb"),
|
MONGODB("MongoDB", "mongodb"),
|
||||||
|
MARIADB("MariaDB", "mariadb"),
|
||||||
MYSQL("MySQL", "mysql"),
|
MYSQL("MySQL", "mysql"),
|
||||||
MYSQL_LEGACY("MySQL-Legacy", "mysql-legacy"),
|
|
||||||
POSTGRESQL("PostgreSQL", "postgresql"),
|
POSTGRESQL("PostgreSQL", "postgresql"),
|
||||||
SQLITE("SQLite", "sqlite"),
|
SQLITE("SQLite", "sqlite"),
|
||||||
H2("H2", "h2");
|
H2("H2", "h2");
|
||||||
|
@ -66,7 +66,7 @@ public class MySQLProvider extends SQLProvider {
|
|||||||
config.setUsername(username);
|
config.setUsername(username);
|
||||||
config.setPassword(password);
|
config.setPassword(password);
|
||||||
|
|
||||||
if (getName().toLowerCase().endsWith("legacy")) {
|
if (!getName().toLowerCase().equals("mariadb")) {
|
||||||
|
|
||||||
// doesn't exist on the MariaDB driver
|
// doesn't exist on the MariaDB driver
|
||||||
config.addDataSourceProperty("cachePrepStmts", "true");
|
config.addDataSourceProperty("cachePrepStmts", "true");
|
||||||
|
@ -43,7 +43,7 @@ public class HikariSupplier implements AutoCloseable {
|
|||||||
hikari = new HikariDataSource();
|
hikari = new HikariDataSource();
|
||||||
hikari.setPoolName(poolName);
|
hikari.setPoolName(poolName);
|
||||||
hikari.setMaximumPoolSize(2);
|
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("serverName", address.split(":")[0]);
|
||||||
hikari.addDataSourceProperty("port", address.split(":")[1]);
|
hikari.addDataSourceProperty("port", address.split(":")[1]);
|
||||||
hikari.addDataSourceProperty("databaseName", database);
|
hikari.addDataSourceProperty("databaseName", database);
|
||||||
|
60
common/src/main/resources/lp-schema-mariadb.sql
Normal file
60
common/src/main/resources/lp-schema-mariadb.sql
Normal 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;
|
@ -147,8 +147,12 @@ meta-formatting {
|
|||||||
# +------------------------------------------------------------------------+ #
|
# +------------------------------------------------------------------------+ #
|
||||||
|
|
||||||
# Which storage method the plugin should use.
|
# 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"
|
storage-method="h2"
|
||||||
|
|
||||||
# When using a file-based storage type, LuckPerms can monitor the data files for changes, and then schedule automatic
|
# When using a file-based storage type, LuckPerms can monitor the data files for changes, and then schedule automatic
|
||||||
|
Loading…
Reference in New Issue
Block a user