Advertisement
Guest User

Untitled

a guest
Nov 10th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. package fr.tolarys.sync;
  2.  
  3. import net.md_5.bungee.api.plugin.Plugin;
  4. import net.md_5.bungee.config.Configuration;
  5. import net.md_5.bungee.config.ConfigurationProvider;
  6. import net.md_5.bungee.config.YamlConfiguration;
  7.  
  8. import java.io.File;
  9. import java.io.IOException;
  10. import java.io.InputStream;
  11. import java.nio.file.Files;
  12. import java.sql.*;
  13.  
  14.  
  15. public class Main extends Plugin {
  16. public Connection pdo;
  17. public Configuration config;
  18.  
  19. private static Main instance;
  20. public static Main getInstance() { return instance; }
  21.  
  22. @Override
  23. public void onEnable() {
  24. instance = this;
  25. if (!getDataFolder().exists())
  26. getDataFolder().mkdir();
  27.  
  28. File file = new File(getDataFolder(), "config.yml");
  29.  
  30.  
  31. if (!file.exists()) try (InputStream in = getResourceAsStream("config.yml")) {
  32. Files.copy(in, file.toPath());
  33. } catch (IOException e) {
  34. e.printStackTrace();
  35. }
  36.  
  37. try {
  38. config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(new File(getDataFolder(), "config.yml"));
  39. } catch (IOException e) {}
  40. openConnection();
  41.  
  42. getProxy().getPluginManager().registerCommand(this, new CreditsCommand());
  43. getProxy().getPluginManager().registerCommand(this, new VoteCommand());
  44. }
  45.  
  46. public Connection getSQL() {
  47. return pdo;
  48. }
  49.  
  50. public void openConnection(){
  51. try {
  52. pdo = DriverManager.getConnection("jdbc:mysql://tristanco.de:3306/site", "server", "LlC320kiwp");
  53. getLogger().info("TolarysSync -> Site: Success...");
  54.  
  55. } catch (SQLException e) {
  56. getLogger().warning("TolarysSync -> Site: Database Error...");
  57. e.printStackTrace();
  58. }
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement