|
14 | 14 |
|
15 | 15 | public class Settings {
|
16 | 16 |
|
| 17 | + private static final HuskTowns plugin = HuskTowns.getInstance(); |
| 18 | + |
17 | 19 | // Locale options
|
18 | 20 | public final String language;
|
19 | 21 |
|
@@ -79,10 +81,10 @@ public class Settings {
|
79 | 81 | private final String serverID;
|
80 | 82 | private final int clusterID;
|
81 | 83 | private final boolean doBungee;
|
82 |
| - private final MessengerType messengerType; |
| 84 | + private MessengerType messengerType; |
83 | 85 |
|
84 | 86 | // Data storage settings
|
85 |
| - private final DatabaseType databaseType; |
| 87 | + private DatabaseType databaseType; |
86 | 88 | private final String playerTable;
|
87 | 89 | private final String townsTable;
|
88 | 90 | private final String claimsTable;
|
@@ -182,13 +184,23 @@ public Settings(FileConfiguration config) {
|
182 | 184 | serverID = config.getString("bungee_options.server_id", "server");
|
183 | 185 | clusterID = config.getInt("bungee_options.cluster_id", 0);
|
184 | 186 | final String messengerTypeConfig = config.getString("bungee_options.messenger_type", "plugin_message");
|
185 |
| - messengerType = messengerTypeConfig.equalsIgnoreCase("pluginmessage") ? MessengerType.PLUGIN_MESSAGE : MessengerType.valueOf(messengerTypeConfig.toUpperCase()); |
| 187 | + try { |
| 188 | + messengerType = messengerTypeConfig.equalsIgnoreCase("pluginmessage") ? MessengerType.PLUGIN_MESSAGE : MessengerType.valueOf(messengerTypeConfig.toUpperCase()); |
| 189 | + } catch (IllegalArgumentException e) { |
| 190 | + plugin.getLogger().warning("Invalid messenger type specified; defaulting to Plugin Message."); |
| 191 | + messengerType = MessengerType.PLUGIN_MESSAGE; |
| 192 | + } |
186 | 193 |
|
187 | 194 | redisHost = config.getString("bungee_options.redis_credentials.host", "localhost");
|
188 | 195 | redisPort = config.getInt("bungee_options.redis_credentials.port", 6379);
|
189 | 196 | redisPassword = config.getString("bungee_options.redis_credentials.password", "");
|
190 | 197 |
|
191 |
| - databaseType = DatabaseType.valueOf(config.getString("data_storage_options.storage_type", "SQLite")); |
| 198 | + try { |
| 199 | + databaseType = DatabaseType.valueOf(config.getString("data_storage_options.storage_type", "SQLite").toUpperCase()); |
| 200 | + } catch (IllegalArgumentException e) { |
| 201 | + databaseType = DatabaseType.SQLITE; |
| 202 | + plugin.getLogger().warning("Invalid database type specified; defaulting to SQLite."); |
| 203 | + } |
192 | 204 | playerTable = config.getString("data_storage_options.table_names.player_table", "husktowns_players");
|
193 | 205 | townsTable = config.getString("data_storage_options.table_names.towns_table", "husktowns_towns");
|
194 | 206 | claimsTable = config.getString("data_storage_options.table_names.claims_table", "husktowns_claims");
|
|
0 commit comments