database not connecting every time an instance is created

This commit is contained in:
NK 2022-12-22 18:46:09 +00:00
parent 2f6281b2aa
commit 3771481d17
2 changed files with 2 additions and 4 deletions

View file

@ -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);

View file

@ -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<Document> getMinersDB() {
return database.getCollection("miners");
}