Skip to content

Commit

Permalink
Add MaxConnections setting for MySQL on BungeeCord
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgH93 committed Nov 25, 2018
1 parent fbff2f5 commit 914b851
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>at.pcgamingfreaks</groupId>
<artifactId>MarriageMaster</artifactId>
<version>1.31.8</version>
<version>1.31.9-SNAPSHOT</version>
<name>MarriageMaster</name>

<repositories>
Expand Down
3 changes: 2 additions & 1 deletion resources/bungee_config.yml
Expand Up @@ -44,6 +44,7 @@ Database:
User: minecraft
Password: minecraft
Properties: []
MaxConnections: 2
Tables:
User: marry_players
Home: marry_home
Expand All @@ -56,4 +57,4 @@ Misc:
DisableV2Info: false

# Config File Version. Don't touch it!
Version: 6
Version: 7
Expand Up @@ -40,7 +40,7 @@ public class Config
private MarriageMaster plugin;
private Configuration config;
private ConfigurationProvider configurationProvider;
private static final int CONFIG_VERSION = 6;
private static final int CONFIG_VERSION = 7;

public Config(MarriageMaster marriagemaster)
{
Expand Down Expand Up @@ -93,6 +93,7 @@ private void updateConfig(File file)
case 3: config.set("Database.MySQL.Properties", new ArrayList<>());
case 4: config.set("Database.UUID_Type", "online");
case 5:
case 6: config.set("Database.MySQL.MaxConnections", 2);
break;
case CONFIG_VERSION: return;
default: plugin.log.info("Config File Version newer than expected!"); return;
Expand Down Expand Up @@ -232,6 +233,11 @@ public String getMySQLProperties()
return str.toString();
}

public int getMySQLMaxConnections()
{
return Math.max(1, config.getInt("Database.MySQL.MaxConnections", 2));
}

public String getUUIDType()
{
return config.getString("Database.UUID_Type", "auto");
Expand Down
Expand Up @@ -54,7 +54,7 @@ public MySQL(MarriageMaster marriagemaster)
poolConfig.setUsername(plugin.config.getMySQLUser());
poolConfig.setPassword(plugin.config.getMySQLPassword());
poolConfig.setMinimumIdle(1);
poolConfig.setMaximumPoolSize(2);
poolConfig.setMaximumPoolSize(plugin.config.getMySQLMaxConnections());
poolConfig.setPoolName("MarriageMaster-Connection-Pool");
poolConfig.addDataSourceProperty("cachePrepStmts", "true");
dataSource = new HikariDataSource(poolConfig);
Expand Down

0 comments on commit 914b851

Please sign in to comment.