Advertisement
Guest User

Untitled

a guest
Nov 7th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.28 KB | None | 0 0
  1. package com.outlook.devleeo.LsFight.utils;
  2.  
  3. import com.outlook.devleeo.LsFight.LsFight;
  4. import com.outlook.devleeo.LsFight.outros.Files;
  5. import java.util.Calendar;
  6. import java.util.logging.Logger;
  7. import org.bukkit.Bukkit;
  8. import org.bukkit.command.ConsoleCommandSender;
  9. import org.bukkit.configuration.file.FileConfiguration;
  10. import org.bukkit.scheduler.BukkitScheduler;
  11.  
  12. public class AutoStart
  13. {
  14. private static boolean in = false;
  15. private static FileConfiguration data = Files.getInstance().getDataFile();
  16.  
  17. private static int getHora(String hora)
  18. {
  19. String str = hora;
  20. switch (hora.hashCode())
  21. {
  22. case 1536:
  23. if (str.equals("00")) {
  24. break;
  25. }
  26. break;
  27. case 1537:
  28. if (str.equals("01")) {}
  29. break;
  30. case 1538:
  31. if (str.equals("02")) {}
  32. break;
  33. case 1539:
  34. if (str.equals("03")) {}
  35. break;
  36. case 1540:
  37. if (str.equals("04")) {}
  38. break;
  39. case 1541:
  40. if (str.equals("05")) {}
  41. break;
  42. case 1542:
  43. if (str.equals("06")) {}
  44. break;
  45. case 1543:
  46. if (str.equals("07")) {}
  47. break;
  48. case 1544:
  49. if (str.equals("08")) {}
  50. break;
  51. case 1545:
  52. if (!str.equals("09"))
  53. {
  54. break label276;
  55. hora = "0";
  56. break label276;
  57. hora = "1";
  58. break label276;
  59. hora = "2";
  60. break label276;
  61. hora = "3";
  62. break label276;
  63. hora = "4";
  64. break label276;
  65. hora = "5";
  66. break label276;
  67. hora = "6";
  68. break label276;
  69. hora = "7";
  70. break label276;
  71. hora = "8";
  72. }
  73. else
  74. {
  75. hora = "9";
  76. }
  77. break;
  78. }
  79. label276:
  80. return Integer.parseInt(hora);
  81. }
  82.  
  83. private static int getMinuto(String minuto)
  84. {
  85. String str = minuto;
  86. switch (minuto.hashCode())
  87. {
  88. case 1536:
  89. if (str.equals("00")) {
  90. break;
  91. }
  92. break;
  93. case 1537:
  94. if (str.equals("01")) {}
  95. break;
  96. case 1538:
  97. if (str.equals("02")) {}
  98. break;
  99. case 1539:
  100. if (str.equals("03")) {}
  101. break;
  102. case 1540:
  103. if (str.equals("04")) {}
  104. break;
  105. case 1541:
  106. if (str.equals("05")) {}
  107. break;
  108. case 1542:
  109. if (str.equals("06")) {}
  110. break;
  111. case 1543:
  112. if (str.equals("07")) {}
  113. break;
  114. case 1544:
  115. if (str.equals("08")) {}
  116. break;
  117. case 1545:
  118. if (!str.equals("09"))
  119. {
  120. break label276;
  121. minuto = "0";
  122. break label276;
  123. minuto = "1";
  124. break label276;
  125. minuto = "2";
  126. break label276;
  127. minuto = "3";
  128. break label276;
  129. minuto = "4";
  130. break label276;
  131. minuto = "5";
  132. break label276;
  133. minuto = "6";
  134. break label276;
  135. minuto = "7";
  136. break label276;
  137. minuto = "8";
  138. }
  139. else
  140. {
  141. minuto = "9";
  142. }
  143. break;
  144. }
  145. label276:
  146. return Integer.parseInt(minuto);
  147. }
  148.  
  149. private static int getDia(String dia)
  150. {
  151. String lowerCase;
  152. switch ((lowerCase = dia.toLowerCase()).hashCode())
  153. {
  154. case -948818302:
  155. if (!lowerCase.equals("quarta")) {
  156. return 0;
  157. }
  158. return 4;
  159. case -948583818:
  160. if (!lowerCase.equals("quinta")) {
  161. return 0;
  162. }
  163. return 5;
  164. case -910017448:
  165. if (!lowerCase.equals("sabado")) {
  166. return 0;
  167. }
  168. return 7;
  169. case 109332819:
  170. if (!lowerCase.equals("sexta")) {
  171. return 0;
  172. }
  173. return 6;
  174. case 110250047:
  175. if (!lowerCase.equals("terca")) {
  176. return 0;
  177. }
  178. break;
  179. case 110254139:
  180. if (!lowerCase.equals("ter�a")) {
  181. return 0;
  182. }
  183. break;
  184. case 1837791503:
  185. if (!lowerCase.equals("domingo")) {
  186. return 0;
  187. }
  188. return 1;
  189. case 1973969579:
  190. if (!lowerCase.equals("segunda")) {
  191. return 0;
  192. }
  193. return 2;
  194. }
  195. return 3;
  196. }
  197.  
  198. public static void checkTempo()
  199. {
  200. try
  201. {
  202. for (String s : LsFight.getInstance().getConfig().getStringList("AutoStart.Horarios"))
  203. {
  204. String[] a = s.split("-");
  205. String[] horario1 = null;
  206. String dia1;
  207. if (a.length == 2)
  208. {
  209. String dia1 = s.split("-")[0];
  210. horario1 = s.split("-")[1].split(":");
  211. }
  212. else
  213. {
  214. dia1 = "";
  215. horario1 = s.split("-")[0].split(":");
  216. }
  217. String dia2 = dia1;
  218. final String[] horario2 = horario1;
  219. Bukkit.getScheduler().scheduleSyncRepeatingTask(LsFight.getInstance(), new Runnable()
  220. {
  221. public void run()
  222. {
  223. if ((Calendar.getInstance().get(7) == AutoStart.getDia(AutoStart.this)) && (Calendar.getInstance().get(11) == AutoStart.getHora(horario2[0])) && (Calendar.getInstance().get(12) == AutoStart.getMinuto(horario2[1])))
  224. {
  225. if ((AutoStart.data.getString("Entrada.") == null) || (AutoStart.data.getString("Saida.") == null) || (AutoStart.data.getString("Pos1.") == null) || (AutoStart.data.getString("Pos2.") == null))
  226. {
  227. Bukkit.getLogger().severe("[LsFight] Nao foi possivel iniciar o evento, entrada, saida, posicao 1 ou posicao 2 nao foi definida.");
  228. Bukkit.getLogger().severe("[LsFight] Nao foi possivel iniciar o evento, entrada, saida, posicao 1 ou posicao 2 nao foi definida.");
  229. Bukkit.getLogger().severe("[LsFight] Nao foi possivel iniciar o evento, entrada, saida, posicao 1 ou posicao 2 nao foi definida.");
  230. return;
  231. }
  232. if (!AutoStart.in)
  233. {
  234. FightUtils.iniciando(LsFight.getInstance().getConfig().getInt("Iniciando.NumeroDeAvisos"));
  235. AutoStart.in = true;
  236. }
  237. }
  238. else if ((Calendar.getInstance().get(11) == AutoStart.getHora(horario2[0])) && (Calendar.getInstance().get(12) == AutoStart.getMinuto(horario2[1])))
  239. {
  240. if ((AutoStart.data.getString("Entrada.") == null) || (AutoStart.data.getString("Saida.") == null) || (AutoStart.data.getString("Pos1.") == null) || (AutoStart.data.getString("Pos2.") == null))
  241. {
  242. Bukkit.getLogger().severe("[LsFight] Nao foi possivel iniciar o evento, entrada, saida, posicao 1 ou posicao 2 nao foi definida.");
  243. Bukkit.getLogger().severe("[LsFight] Nao foi possivel iniciar o evento, entrada, saida, posicao 1 ou posicao 2 nao foi definida.");
  244. Bukkit.getLogger().severe("[LsFight] Nao foi possivel iniciar o evento, entrada, saida, posicao 1 ou posicao 2 nao foi definida.");
  245. return;
  246. }
  247. if (!AutoStart.in)
  248. {
  249. FightUtils.iniciando(LsFight.getInstance().getConfig().getInt("Iniciando.NumeroDeAvisos"));
  250. AutoStart.in = true;
  251. }
  252. }
  253. }
  254. }, 0L, 200L);
  255. }
  256. }
  257. catch (Exception e)
  258. {
  259. Bukkit.getConsoleSender().sendMessage("�4[MVP] �cErro na configuracao dos horarios.");
  260. }
  261. }
  262. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement