Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DatabaseConfig {
- private Plugin plugin;
- private FileConfiguration config;
- private CommandSender sender;
- // Fields to retrieve
- private String host;
- private int port;
- private String db;
- private boolean auth;
- private String user;
- private char[] pass;
- public DatabaseConfig(Plugin plugin) {
- this.plugin = plugin;
- config = plugin.getConfig();
- sender = plugin.getServer().getConsoleSender();
- loadConfig();
- }
- public void loadConfig() {
- File configFile = new File(plugin.getDataFolder(), "config.yml");
- if(!configFile.exists()) {
- sender.sendMessage("config.yml file not found, using default values");
- sender.sendMessage("Generating default config.yml file.");
- plugin.saveDefaultConfig();
- }
- host = config.getString("host", "127.0.0.1");
- port = config.getInt("port", 27017);
- db = config.getString("db", "mydb");
- auth = config.getBoolean("auth", false);
- user = config.getString("user", "user");
- pass = config.getString("pass", "pass").toCharArray();
- }
- public String getHost() {
- return host;
- }
- public int getPort() {
- return port;
- }
- public String getDb() {
- return db;
- }
- public boolean hasAuth() {
- return auth;
- }
- public String getUser() {
- return user;
- }
- public char[] getPass() {
- return pass;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement