Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package club.mrwizox.practice.database;
- import java.util.*;
- import com.mongodb.MongoClient;
- import com.mongodb.MongoCredential;
- import com.mongodb.ServerAddress;
- import com.mongodb.client.MongoCollection;
- import com.mongodb.client.MongoDatabase;
- import club.mrwizox.practice.Practice;
- public class PracticeDatabase
- {
- private MongoClient client;
- private MongoDatabase database;
- @SuppressWarnings("rawtypes")
- private MongoCollection profiles;
- @SuppressWarnings("rawtypes")
- private MongoCollection kits;
- @SuppressWarnings("rawtypes")
- private MongoCollection points;
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public PracticeDatabase(final Practice Practice) {
- this.client = (Practice.getConfig().getBoolean("DATABASE.MONGO.AUTHENTICATION.ENABLED") ? new MongoClient(new ServerAddress(Practice.getConfig().getString("DATABASE.MONGO.HOST"), Practice.getConfig().getInt("DATABASE.MONGO.PORT")), (List)Arrays.asList(MongoCredential.createCredential(Practice.getConfig().getString("DATABASE.MONGO.AUTHENTICATION.USER"), Practice.getConfig().getString("DATABASE.MONGO.AUTHENTICATION.DATABASE"), Practice.getConfig().getString("DATABASE.MONGO.AUTHENTICATION.PASSWORD").toCharArray()))) : new MongoClient(new ServerAddress(Practice.getConfig().getString("DATABASE.MONGO.HOST"), Practice.getConfig().getInt("DATABASE.MONGO.PORT"))));
- this.database = this.client.getDatabase("practice");
- this.profiles = this.database.getCollection("profiles");
- this.kits = this.database.getCollection("kits");
- this.points = this.database.getCollection("points");
- }
- public MongoClient getClient() {
- return this.client;
- }
- public MongoDatabase getDatabase() {
- return this.database;
- }
- @SuppressWarnings("rawtypes")
- public MongoCollection getProfiles() {
- return this.profiles;
- }
- @SuppressWarnings("rawtypes")
- public MongoCollection getKits() {
- return this.kits;
- }
- @SuppressWarnings("rawtypes")
- public MongoCollection getPoints() {
- return this.points;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement