Advertisement
Guest User

Untitled

a guest
Nov 5th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. package tequilaxbr.aventury.coins;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5.  
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.plugin.java.JavaPlugin;
  8.  
  9. import tequilaxbr.aventury.coins.api.CoinsAPI;
  10. import tequilaxbr.aventury.coins.commands.CoinsCommand;
  11. import tequilaxbr.aventury.coins.database.SQL;
  12. import tequilaxbr.aventury.coins.database.SQL.SQLType;
  13. import tequilaxbr.aventury.coins.listeners.CreateAccountListener;
  14.  
  15. public class Coins extends JavaPlugin{
  16.  
  17. private SQL sql;
  18. private static CoinsAPI coinsAPI;
  19.  
  20. public void onEnable() {
  21. saveDefaultConfig();
  22. if(!getConfig().getBoolean("MySQL.Ativar")){
  23. File db = new File(getDataFolder() + File.separator + "Coins.db");
  24. if(!db.exists()){
  25. try {
  26. db.createNewFile();
  27. } catch (IOException e) {
  28. e.printStackTrace();
  29. }
  30. }
  31. }
  32. if(getConfig().getBoolean("MySQL.Ativar")){
  33. String user, password, host, database;
  34. user = getConfig().getString("MySQL.User");
  35. password = getConfig().getString("MySQL.Password");
  36. host = getConfig().getString("MySQL.Host");
  37. database = getConfig().getString("MySQL.Database");
  38. this.sql = new SQL(user, password, host, database, SQLType.MySQL, this);
  39. this.sql.startConnection();
  40. }else{
  41. this.sql = new SQL("Coins", getDataFolder(), SQLType.SQLite, this);
  42. this.sql.startConnection();
  43. }
  44. getCommand("coins").setExecutor(new CoinsCommand(this));
  45. Bukkit.getPluginManager().registerEvents(new CreateAccountListener(this), this);
  46. coinsAPI = new CoinsAPI(this);
  47. }
  48.  
  49. public void onDisable() {
  50. getSQL().closeConnection();
  51. }
  52.  
  53. public static CoinsAPI getCoinsAPI(){
  54. return coinsAPI;
  55. }
  56.  
  57. public SQL getSQL(){
  58. return sql;
  59. }
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement