From 3c461c6307600b4cc47ef9cef68ef74696c952eb Mon Sep 17 00:00:00 2001 From: ham1255 Date: Tue, 7 Jul 2020 18:49:19 +0400 Subject: [PATCH] added mongodb, bumped versoin --- pom.xml | 7 ++++- .../net/limework/core/LimeworkSpigotCore.java | 12 ++++++++ .../core/managers/DataSourcesManager.java | 29 +++++++++++++++++++ src/main/resources/config.yml | 6 +++- 4 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 src/main/java/net/limework/core/managers/DataSourcesManager.java diff --git a/pom.xml b/pom.xml index be30191..f7d5f65 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.limework.core LimeworkSpigotCore - 1.0.0-SNAPSHOT + 1.0.1-SNAPSHOT jar @@ -112,5 +112,10 @@ 19.0.0 compile + + org.mongodb + mongodb-driver-sync + 4.0.4 + \ No newline at end of file diff --git a/src/main/java/net/limework/core/LimeworkSpigotCore.java b/src/main/java/net/limework/core/LimeworkSpigotCore.java index 7aec165..1a8d58e 100644 --- a/src/main/java/net/limework/core/LimeworkSpigotCore.java +++ b/src/main/java/net/limework/core/LimeworkSpigotCore.java @@ -2,6 +2,7 @@ package net.limework.core; import net.limework.core.guis.ControlGui; import net.limework.core.hooks.SkriptHook; +import net.limework.core.managers.DataSourcesManager; import net.limework.core.managers.RedisManager; import org.bukkit.plugin.java.JavaPlugin; @@ -10,6 +11,9 @@ public class LimeworkSpigotCore extends JavaPlugin { //Redis manager private RedisManager rm; + //data + private DataSourcesManager dsm; + @Override public void onEnable() { @@ -29,6 +33,9 @@ public class LimeworkSpigotCore extends JavaPlugin { getLogger().info("SOMETHING WENT WRONG WHEN LOADING control gui."); e.printStackTrace(); } + dsm = new DataSourcesManager(this); + + } @@ -36,10 +43,15 @@ public class LimeworkSpigotCore extends JavaPlugin { @Override public void onDisable() { rm.shutdown(); + dsm.shutdown(); } public RedisManager getRm() { return rm; } + + public DataSourcesManager getDsm() { + return dsm; + } } \ No newline at end of file diff --git a/src/main/java/net/limework/core/managers/DataSourcesManager.java b/src/main/java/net/limework/core/managers/DataSourcesManager.java new file mode 100644 index 0000000..fa92ca8 --- /dev/null +++ b/src/main/java/net/limework/core/managers/DataSourcesManager.java @@ -0,0 +1,29 @@ +package net.limework.core.managers; + +import com.mongodb.client.MongoClient; +import com.mongodb.client.MongoClients; +import net.limework.core.LimeworkSpigotCore; +import org.bukkit.configuration.Configuration; + +public class DataSourcesManager { + + private MongoClient mongoClient; + + + public DataSourcesManager(LimeworkSpigotCore plugin) { + Configuration config = plugin .getConfig(); + if (config.getBoolean("Mongodb.enabled")){ + mongoClient = MongoClients.create(); + } + } + + public void shutdown(){ + mongoClient.close(); + } + + + + public MongoClient getMongoClient() { + return mongoClient; + } +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 54dfb9d..8d9da16 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -14,4 +14,8 @@ Redis: Channels: - "Channel1" - "Channel2" - - "Channel3" \ No newline at end of file + - "Channel3" + +Mongodb: + enabled: false + url: "" \ No newline at end of file