Search in sources :

Example 6 with RegionDriver

use of com.sk89q.worldguard.protection.managers.storage.RegionDriver in project WorldGuard by EngineHub.

the class YamlConfigurationManager method load.

@Override
public void load() {
    copyDefaults();
    config = new YAMLProcessor(new File(getDataFolder(), "config.yml"), true, YAMLFormat.EXTENDED);
    try {
        config.load();
    } catch (IOException e) {
        log.severe("Error reading configuration for global config: ");
        e.printStackTrace();
    }
    config.removeProperty("suppress-tick-sync-warnings");
    migrateRegionsToUuid = config.getBoolean("regions.uuid-migration.perform-on-next-start", true);
    keepUnresolvedNames = config.getBoolean("regions.uuid-migration.keep-names-that-lack-uuids", true);
    useRegionsCreatureSpawnEvent = config.getBoolean("regions.use-creature-spawn-event", true);
    disableDefaultBypass = config.getBoolean("regions.disable-bypass-by-default", false);
    announceBypassStatus = config.getBoolean("regions.announce-bypass-status", false);
    useGodPermission = config.getBoolean("auto-invincible", config.getBoolean("auto-invincible-permission", false));
    useGodGroup = config.getBoolean("auto-invincible-group", false);
    useAmphibiousGroup = config.getBoolean("auto-no-drowning-group", false);
    config.removeProperty("auto-invincible-permission");
    usePlayerMove = config.getBoolean("use-player-move-event", true);
    usePlayerTeleports = config.getBoolean("use-player-teleports", true);
    particleEffects = config.getBoolean("use-particle-effects", true);
    disablePermissionCache = config.getBoolean("disable-permission-cache", false);
    deopOnJoin = config.getBoolean("security.deop-everyone-on-join", false);
    blockInGameOp = config.getBoolean("security.block-in-game-op-command", false);
    hostKeys = new HashMap<>();
    Object hostKeysRaw = config.getProperty("host-keys");
    if (!(hostKeysRaw instanceof Map)) {
        config.setProperty("host-keys", new HashMap<String, String>());
    } else {
        for (Map.Entry<Object, Object> entry : ((Map<Object, Object>) hostKeysRaw).entrySet()) {
            String key = String.valueOf(entry.getKey());
            String value = String.valueOf(entry.getValue());
            hostKeys.put(key.toLowerCase(), value);
        }
    }
    hostKeysAllowFMLClients = config.getBoolean("security.host-keys-allow-forge-clients", false);
    // ====================================================================
    // Region store drivers
    // ====================================================================
    boolean useSqlDatabase = config.getBoolean("regions.sql.use", false);
    String sqlDsn = config.getString("regions.sql.dsn", "jdbc:mysql://localhost/worldguard");
    String sqlUsername = config.getString("regions.sql.username", "worldguard");
    String sqlPassword = config.getString("regions.sql.password", "worldguard");
    String sqlTablePrefix = config.getString("regions.sql.table-prefix", "");
    if (!useSqlDatabase) {
        config.removeProperty("regions.sql");
    } else {
        log.warning("SQL support for WorldGuard region storage is deprecated for removal in a future version. Please migrate to YAML storage.");
        log.warning("For details, see https://worldguard.enginehub.org/en/latest/regions/storage/");
    }
    DataSourceConfig dataSourceConfig = new DataSourceConfig(sqlDsn, sqlUsername, sqlPassword, sqlTablePrefix);
    SQLDriver sqlDriver = new SQLDriver(dataSourceConfig);
    DirectoryYamlDriver yamlDriver = new DirectoryYamlDriver(getWorldsDataFolder(), "regions.yml");
    this.regionStoreDriverMap = ImmutableMap.<DriverType, RegionDriver>builder().put(DriverType.MYSQL, sqlDriver).put(DriverType.YAML, yamlDriver).build();
    this.selectedRegionStoreDriver = useSqlDatabase ? sqlDriver : yamlDriver;
    postLoad();
    config.setHeader(CONFIG_HEADER);
}
Also used : DirectoryYamlDriver(com.sk89q.worldguard.protection.managers.storage.file.DirectoryYamlDriver) DataSourceConfig(com.sk89q.worldguard.util.sql.DataSourceConfig) IOException(java.io.IOException) RegionDriver(com.sk89q.worldguard.protection.managers.storage.RegionDriver) YAMLProcessor(com.sk89q.util.yaml.YAMLProcessor) SQLDriver(com.sk89q.worldguard.protection.managers.storage.sql.SQLDriver) DriverType(com.sk89q.worldguard.protection.managers.storage.DriverType) File(java.io.File) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

RegionDriver (com.sk89q.worldguard.protection.managers.storage.RegionDriver)6 CommandException (com.sk89q.minecraft.util.commands.CommandException)4 CommandPermissionsException (com.sk89q.minecraft.util.commands.CommandPermissionsException)4 LocalPlayer (com.sk89q.worldguard.LocalPlayer)4 Logger (java.util.logging.Logger)4 Command (com.sk89q.minecraft.util.commands.Command)3 MigrationException (com.sk89q.worldguard.protection.managers.migration.MigrationException)3 ConfigurationManager (com.sk89q.worldguard.config.ConfigurationManager)2 DirectoryYamlDriver (com.sk89q.worldguard.protection.managers.storage.file.DirectoryYamlDriver)2 SQLDriver (com.sk89q.worldguard.protection.managers.storage.sql.SQLDriver)2 RegionContainer (com.sk89q.worldguard.protection.regions.RegionContainer)2 LoggerToChatHandler (com.sk89q.worldguard.util.logging.LoggerToChatHandler)2 File (java.io.File)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 CommandsManagerRegistration (com.sk89q.bukkit.util.CommandsManagerRegistration)1 CommandUsageException (com.sk89q.minecraft.util.commands.CommandUsageException)1