Skip to content

Commit

Permalink
Fix IllegalArgumentException with new enums
Browse files Browse the repository at this point in the history
Signed-off-by: William <[email protected]>
  • Loading branch information
WiIIiam278 committed Nov 14, 2021
1 parent df45b27 commit 4c3f3aa
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions bukkit/src/main/java/me/william278/husktowns/config/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

public class Settings {

private static final HuskTowns plugin = HuskTowns.getInstance();

// Locale options
public final String language;

Expand Down Expand Up @@ -79,10 +81,10 @@ public class Settings {
private final String serverID;
private final int clusterID;
private final boolean doBungee;
private final MessengerType messengerType;
private MessengerType messengerType;

// Data storage settings
private final DatabaseType databaseType;
private DatabaseType databaseType;
private final String playerTable;
private final String townsTable;
private final String claimsTable;
Expand Down Expand Up @@ -182,13 +184,23 @@ public Settings(FileConfiguration config) {
serverID = config.getString("bungee_options.server_id", "server");
clusterID = config.getInt("bungee_options.cluster_id", 0);
final String messengerTypeConfig = config.getString("bungee_options.messenger_type", "plugin_message");
messengerType = messengerTypeConfig.equalsIgnoreCase("pluginmessage") ? MessengerType.PLUGIN_MESSAGE : MessengerType.valueOf(messengerTypeConfig.toUpperCase());
try {
messengerType = messengerTypeConfig.equalsIgnoreCase("pluginmessage") ? MessengerType.PLUGIN_MESSAGE : MessengerType.valueOf(messengerTypeConfig.toUpperCase());
} catch (IllegalArgumentException e) {
plugin.getLogger().warning("Invalid messenger type specified; defaulting to Plugin Message.");
messengerType = MessengerType.PLUGIN_MESSAGE;
}

redisHost = config.getString("bungee_options.redis_credentials.host", "localhost");
redisPort = config.getInt("bungee_options.redis_credentials.port", 6379);
redisPassword = config.getString("bungee_options.redis_credentials.password", "");

databaseType = DatabaseType.valueOf(config.getString("data_storage_options.storage_type", "SQLite"));
try {
databaseType = DatabaseType.valueOf(config.getString("data_storage_options.storage_type", "SQLite").toUpperCase());
} catch (IllegalArgumentException e) {
databaseType = DatabaseType.SQLITE;
plugin.getLogger().warning("Invalid database type specified; defaulting to SQLite.");
}
playerTable = config.getString("data_storage_options.table_names.player_table", "husktowns_players");
townsTable = config.getString("data_storage_options.table_names.towns_table", "husktowns_towns");
claimsTable = config.getString("data_storage_options.table_names.claims_table", "husktowns_claims");
Expand Down

0 comments on commit 4c3f3aa

Please sign in to comment.