aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorLMBishop <13875753+LMBishop@users.noreply.github.com>2021-06-03 18:41:00 +0100
committerLMBishop <13875753+LMBishop@users.noreply.github.com>2021-06-03 18:41:00 +0100
commit22819bf95e3d097c4c5dededf774854afc360eaf (patch)
tree7fe7e84a34e08bbec1f535f78572a4eac4d17dd7 /src/main
parente87c40a581a5dde310cba7a168e532c837f2efc6 (diff)
Make storage provider configurable
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/leonardobishop/quests/player/QPlayerManager.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/main/java/com/leonardobishop/quests/player/QPlayerManager.java b/src/main/java/com/leonardobishop/quests/player/QPlayerManager.java
index bd7ccf37..836479a1 100644
--- a/src/main/java/com/leonardobishop/quests/player/QPlayerManager.java
+++ b/src/main/java/com/leonardobishop/quests/player/QPlayerManager.java
@@ -25,9 +25,18 @@ public class QPlayerManager {
private StorageProvider storageProvider;
public QPlayerManager(Quests plugin) {
- this.storageProvider = new MySqlStorageProvider(plugin, plugin.getConfig().getConfigurationSection("options.storage.database-settings"));
- storageProvider.init();
this.plugin = plugin;
+
+ String configuredProvider = plugin.getConfig().getString("options.storage.provider", "yaml");
+ if (configuredProvider.equalsIgnoreCase("yaml")) {
+ this.storageProvider = new YamlStorageProvider(plugin);
+ } else if (configuredProvider.equalsIgnoreCase("mysql")) {
+ this.storageProvider = new MySqlStorageProvider(plugin, plugin.getConfig().getConfigurationSection("options.storage.database-settings"));
+ } else {
+ plugin.getQuestsLogger().warning("No valid storage provider is configured - Quests will use YAML storage as a default");
+ this.storageProvider = new YamlStorageProvider(plugin);
+ }
+ storageProvider.init();
}
private final Map<UUID, QPlayer> qPlayers = new ConcurrentHashMap<>();