Advertisement
Guest User

Untitled

a guest
May 31st, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. @SuppressWarnings("deprecation")
  2. private void loadConfig() throws IOException {
  3. File jarFile = new File(Configuration.class.getProtectionDomain().getCodeSource().getLocation().getPath());
  4. File configFile = new File(URLDecoder.decode(jarFile.getParent() + "//EventManager//config.yml"));
  5. BufferedReader inputStream = null;
  6. try {
  7. String line;
  8. inputStream = new BufferedReader(new FileReader(configFile));
  9. while ((line = inputStream.readLine()) != null) {
  10. if (line.startsWith("banTime: ")) {
  11. try {
  12. banTime = Integer.parseInt(line.replaceFirst("banTime: ", ""));
  13. } catch (Exception e) {
  14. banTime = 4320;
  15. }
  16. } else if (line.startsWith("premiumEventCost: ")) {
  17. try {
  18. premiumCost = Integer.parseInt(line.replaceFirst("premiumEventCost: ", ""));
  19. } catch (Exception e) {
  20. premiumCost = 10000;
  21. }
  22. } else if (line.startsWith("username: ")) {
  23. username = line.replaceFirst("username: ", "");
  24. } else if (line.startsWith("password: ")) {
  25. password = line.replaceFirst("password: ", "");
  26. } else if (line.startsWith("uri: ")) {
  27. url = "jdbc:" + line.replaceFirst("uri: ", "");
  28. }
  29. }
  30. } finally {
  31. if (inputStream != null) {
  32. inputStream.close();
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement