From 3771481d1779beca62e98fa0f7f75ffdf114a9df Mon Sep 17 00:00:00 2001 From: NK Date: Thu, 22 Dec 2022 18:46:09 +0000 Subject: [PATCH] database not connecting every time an instance is created --- src/main/java/me/night/nullvalkyrie/Main.java | 2 +- .../java/me/night/nullvalkyrie/database/DatabaseManager.java | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/night/nullvalkyrie/Main.java b/src/main/java/me/night/nullvalkyrie/Main.java index 6635e0c..d20e8ec 100644 --- a/src/main/java/me/night/nullvalkyrie/Main.java +++ b/src/main/java/me/night/nullvalkyrie/Main.java @@ -18,7 +18,7 @@ public final class Main extends JavaPlugin { @Override public void onEnable() { EnchantmentManager.register(); - new DatabaseManager(); + new DatabaseManager().connect(); new CommandManager(); Bukkit.getPluginManager().registerEvents(new ServerEvents(), this); Bukkit.getPluginManager().registerEvents(new InventoryListener(), this); diff --git a/src/main/java/me/night/nullvalkyrie/database/DatabaseManager.java b/src/main/java/me/night/nullvalkyrie/database/DatabaseManager.java index 8275c0f..79c2edf 100644 --- a/src/main/java/me/night/nullvalkyrie/database/DatabaseManager.java +++ b/src/main/java/me/night/nullvalkyrie/database/DatabaseManager.java @@ -5,11 +5,9 @@ import org.bson.Document; public class DatabaseManager { public static MongoDatabase database; - - public DatabaseManager() { + public void connect() { database = MongoClients.create(System.getenv("MONGODB_URI")).getDatabase("NullValkyrie"); } - public MongoCollection getMinersDB() { return database.getCollection("miners"); }