Advertisement
Guest User

Untitled

a guest
Apr 17th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.03 KB | None | 0 0
  1. package pl.selnq.config;
  2.  
  3. import org.bukkit.configuration.file.FileConfiguration;
  4. import pl.selnq.CorePlugin;
  5.  
  6. import java.lang.reflect.Field;
  7.  
  8. public class Config {
  9.  
  10. private static final String prefix = "config.";
  11.  
  12. public static String DATABASE_SQLITE_NAME = "minecraft.db";
  13. public static String DATABASE_MODE = "sqlite";
  14. public static String DATABASE_TABLEPREFIX = "LootMc ";
  15. public static String DATABASE_MYSQL_HOST = "s12.crafthost.pl";
  16. public static int DATABASE_MYSQL_PORT = 3306;
  17. public static String DATABASE_MYSQL_USER = "svr49514";
  18. public static String DATABASE_MYSQL_PASS = "ConsulatioN543";
  19. public static String DATABASE_MYSQL_NAME = "minecraft";
  20. public static String RANKS_GROUPS_PLAYER_FULL$NAME;
  21. public static int RANKS_GROUPS_PLAYER_PERMISSION$LVL;
  22. public static String RANKS_GROUPS_PLAYER_PREFIX;
  23. public static String RANKS_GROUPS_PLAYER_SUFFIX;
  24. public static String RANKS_GROUPS_VIP_FULL$NAME;
  25. public static int RANKS_GROUPS_VIP_PERMISSION$LVL;
  26. public static String RANKS_GROUPS_VIP_PREFIX;
  27. public static String RANKS_GROUPS_VIP_SUFFIX;
  28. public static String RANKS_GROUPS_SVIP_FULL$NAME;
  29. public static int RANKS_GROUPS_SVIP_PERMISSION$LVL;
  30. public static String RANKS_GROUPS_SVIP_PREFIX;
  31. public static String RANKS_GROUPS_SVIP_SUFFIX;
  32. public static String MSG_ERROR_DONTHAVEPERMISSION;
  33. public static int CHAT_SLOWMODE;
  34. public static String CHAT_FORMAT_GLOBAL;
  35. public static String CHAT_FORMAT_ADMIN;
  36. static {
  37. MSG_ERROR_DONTHAVEPERMISSION = "Nie masz permisji xd";
  38. RANKS_GROUPS_PLAYER_FULL$NAME = "PLAYER";
  39. RANKS_GROUPS_PLAYER_PERMISSION$LVL = 0;
  40. RANKS_GROUPS_PLAYER_PREFIX = "&7";
  41. RANKS_GROUPS_PLAYER_SUFFIX = "&7";
  42. RANKS_GROUPS_VIP_FULL$NAME = "VIP";
  43. RANKS_GROUPS_VIP_PERMISSION$LVL = 1;
  44. RANKS_GROUPS_VIP_PREFIX = "&6Vip &7";
  45. RANKS_GROUPS_VIP_SUFFIX = "&7";
  46. RANKS_GROUPS_SVIP_FULL$NAME = "SVIP";
  47. RANKS_GROUPS_SVIP_PERMISSION$LVL = 1;
  48. RANKS_GROUPS_SVIP_PREFIX = "&6Svip &7";
  49. RANKS_GROUPS_SVIP_SUFFIX = "&7";
  50. RANKS_GROUPS_SPONSOR_FULL$NAME = "SPONSOR";
  51. RANKS_GROUPS_SPONSOR_PERMISSION$LVL = 2;
  52. RANKS_GROUPS_SPONSOR_PREFIX = "&9Sponsor &7";
  53. RANKS_GROUPS_SPONSOR_SUFFIX = "&7";
  54. CHAT_FORMAT_GLOBAL = "{GUILD} &8[&7{POINTS}&8] &7{PREFIX}{PLAYER}&8: &7{SUFFIX}{MESSAGE}";
  55. CHAT_FORMAT_ADMIN = "&7{PREFIX}{PLAYER}&8: &7{SUFFIX}{MESSAGE}";
  56. CHAT_SLOWMODE = 10;
  57.  
  58. }
  59. public static String RANKS_GROUPS_STREAMER_FULL$NAME = "STREAMER";
  60. public static int RANKS_GROUPS_STREAMER_PERMISSION$LVL = 2;
  61. public static String RANKS_GROUPS_STREAMER_PREFIX = "&5Streamer &7";
  62. public static String RANKS_GROUPS_STREAMER_SUFFIX = "&7";
  63. public static String RANKS_GROUPS_YOUTUBER_FULL$NAME = "YOUTUBER";
  64. public static int RANKS_GROUPS_YOUTUBER_PERMISSION$LVL = 2;
  65. public static String RANKS_GROUPS_YOUTUBER_PREFIX = "&fYou&cTuber &7";
  66. public static String RANKS_GROUPS_YOUTUBER_SUFFIX = "&7";
  67. public static String RANKS_GROUPS_HELPER_FULL$NAME = "HELPER";
  68. public static int RANKS_GROUPS_HELPER_PERMISSION$LVL = 3;
  69. public static String RANKS_GROUPS_HELPER_PREFIX = "&3Helper &7";
  70. public static String RANKS_GROUPS_HELPER_SUFFIX = "&b";
  71. public static String RANKS_GROUPS_MODERATOR_FULL$NAME = "MODERATOR";
  72. public static int RANKS_GROUPS_MODERATOR_PERMISSION$LVL = 4;
  73. public static String RANKS_GROUPS_MODERATOR_PREFIX = "&2Moderator &7";
  74. public static String RANKS_GROUPS_MODERATOR_SUFFIX = "&a";
  75. public static String RANKS_GROUPS_ADMIN_FULL$NAME = "ADMIN";
  76. public static int RANKS_GROUPS_ADMIN_PERMISSION$LVL = 5;
  77. public static String RANKS_GROUPS_ADMIN_PREFIX = "&cAdmin &7";
  78. public static String RANKS_GROUPS_ADMIN_SUFFIX = "&6";
  79. public static String RANKS_GROUPS_HEADADMIN_FULL$NAME = "HEADADMIN";
  80. public static int RANKS_GROUPS_HEADADMIN_PERMISSION$LVL = 6;
  81. public static String RANKS_GROUPS_HEADADMIN_PREFIX = "&4HeadAdmin &7";
  82. public static String RANKS_GROUPS_HEADADMIN_SUFFIX = "&6";
  83. public static String RANKS_GROUPS_ROOT_FULL$NAME = "ROOT";
  84. public static int RANKS_GROUPS_ROOT_PERMISSION$LVL = 999;
  85. public static String RANKS_GROUPS_ROOT_PREFIX = "&4Root &7";
  86. public static String RANKS_GROUPS_ROOT_SUFFIX = "&6&l";
  87. public static String RANKS_GROUPS_SPONSOR_FULL$NAME;
  88. public static int RANKS_GROUPS_SPONSOR_PERMISSION$LVL;
  89. public static String RANKS_GROUPS_SPONSOR_PREFIX;
  90. public static String RANKS_GROUPS_SPONSOR_SUFFIX;
  91.  
  92. public static void loadConfig()
  93. {
  94. try
  95. {
  96. CorePlugin.getPlugin().saveDefaultConfig();
  97. FileConfiguration c = CorePlugin.getPlugin().getConfig();
  98. Field[] fields;
  99. int length = (fields = Config.class.getFields()).length;
  100. for (int i = 0; i < length; i++)
  101. {
  102. Field f = fields[i];
  103. if (c.isSet("config." + f.getName().toLowerCase().replace("_", "."))) {
  104. f.set(null, c.get("config." + f.getName().toLowerCase().replace("_", ".")));
  105. }
  106. }
  107. }
  108. catch (Exception e)
  109. {
  110. e.printStackTrace();
  111. }
  112. }
  113.  
  114. public static void saveConfig()
  115. {
  116. try
  117. {
  118. FileConfiguration c = CorePlugin.getPlugin().getConfig();
  119. Field[] fields;
  120. int length = (fields = Config.class.getFields()).length;
  121. for (int i = 0; i < length; i++)
  122. {
  123. Field f = fields[i];
  124. c.set("config." + f.getName().toLowerCase().replace("_", "."), f.get(null));
  125. }
  126. CorePlugin.getPlugin().saveConfig();
  127. }
  128. catch (Exception e)
  129. {
  130. e.printStackTrace();
  131. }
  132. }
  133.  
  134. public static void reloadConfig()
  135. {
  136. CorePlugin.getPlugin().reloadConfig();
  137. loadConfig();
  138. saveConfig();
  139. }
  140. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement