database not connecting every time an instance is created
This commit is contained in:
parent
2f6281b2aa
commit
3771481d17
2 changed files with 2 additions and 4 deletions
|
@ -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);
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue