SHARE
TWEET

Untitled

a guest Jul 15th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package club.mrwizox.practice.database;
  2.  
  3. import java.util.*;
  4.  
  5. import com.mongodb.MongoClient;
  6. import com.mongodb.MongoCredential;
  7. import com.mongodb.ServerAddress;
  8. import com.mongodb.client.MongoCollection;
  9. import com.mongodb.client.MongoDatabase;
  10.  
  11. import club.mrwizox.practice.Practice;
  12.  
  13. public class PracticeDatabase
  14. {
  15.     private MongoClient client;
  16.     private MongoDatabase database;
  17.     @SuppressWarnings("rawtypes")
  18.     private MongoCollection profiles;
  19.     @SuppressWarnings("rawtypes")
  20.     private MongoCollection kits;
  21.     @SuppressWarnings("rawtypes")
  22.     private MongoCollection points;
  23.    
  24.     @SuppressWarnings({ "unchecked", "rawtypes" })
  25.     public PracticeDatabase(final Practice Practice) {
  26.         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"))));
  27.         this.database = this.client.getDatabase("practice");
  28.         this.profiles = this.database.getCollection("profiles");
  29.         this.kits = this.database.getCollection("kits");
  30.         this.points = this.database.getCollection("points");
  31.     }
  32.    
  33.     public MongoClient getClient() {
  34.         return this.client;
  35.     }
  36.    
  37.     public MongoDatabase getDatabase() {
  38.         return this.database;
  39.     }
  40.    
  41.     @SuppressWarnings("rawtypes")
  42.     public MongoCollection getProfiles() {
  43.         return this.profiles;
  44.     }
  45.    
  46.     @SuppressWarnings("rawtypes")
  47.     public MongoCollection getKits() {
  48.         return this.kits;
  49.     }
  50.    
  51.     @SuppressWarnings("rawtypes")
  52.     public MongoCollection getPoints() {
  53.         return this.points;
  54.     }
  55. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top