Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.outlook.devleeo.LsFight.utils;
- import com.outlook.devleeo.LsFight.LsFight;
- import com.outlook.devleeo.LsFight.outros.Files;
- import java.util.Calendar;
- import java.util.logging.Logger;
- import org.bukkit.Bukkit;
- import org.bukkit.command.ConsoleCommandSender;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.scheduler.BukkitScheduler;
- public class AutoStart
- {
- private static boolean in = false;
- private static FileConfiguration data = Files.getInstance().getDataFile();
- private static int getHora(String hora)
- {
- String str = hora;
- switch (hora.hashCode())
- {
- case 1536:
- if (str.equals("00")) {
- break;
- }
- break;
- case 1537:
- if (str.equals("01")) {}
- break;
- case 1538:
- if (str.equals("02")) {}
- break;
- case 1539:
- if (str.equals("03")) {}
- break;
- case 1540:
- if (str.equals("04")) {}
- break;
- case 1541:
- if (str.equals("05")) {}
- break;
- case 1542:
- if (str.equals("06")) {}
- break;
- case 1543:
- if (str.equals("07")) {}
- break;
- case 1544:
- if (str.equals("08")) {}
- break;
- case 1545:
- if (!str.equals("09"))
- {
- break label276;
- hora = "0";
- break label276;
- hora = "1";
- break label276;
- hora = "2";
- break label276;
- hora = "3";
- break label276;
- hora = "4";
- break label276;
- hora = "5";
- break label276;
- hora = "6";
- break label276;
- hora = "7";
- break label276;
- hora = "8";
- }
- else
- {
- hora = "9";
- }
- break;
- }
- label276:
- return Integer.parseInt(hora);
- }
- private static int getMinuto(String minuto)
- {
- String str = minuto;
- switch (minuto.hashCode())
- {
- case 1536:
- if (str.equals("00")) {
- break;
- }
- break;
- case 1537:
- if (str.equals("01")) {}
- break;
- case 1538:
- if (str.equals("02")) {}
- break;
- case 1539:
- if (str.equals("03")) {}
- break;
- case 1540:
- if (str.equals("04")) {}
- break;
- case 1541:
- if (str.equals("05")) {}
- break;
- case 1542:
- if (str.equals("06")) {}
- break;
- case 1543:
- if (str.equals("07")) {}
- break;
- case 1544:
- if (str.equals("08")) {}
- break;
- case 1545:
- if (!str.equals("09"))
- {
- break label276;
- minuto = "0";
- break label276;
- minuto = "1";
- break label276;
- minuto = "2";
- break label276;
- minuto = "3";
- break label276;
- minuto = "4";
- break label276;
- minuto = "5";
- break label276;
- minuto = "6";
- break label276;
- minuto = "7";
- break label276;
- minuto = "8";
- }
- else
- {
- minuto = "9";
- }
- break;
- }
- label276:
- return Integer.parseInt(minuto);
- }
- private static int getDia(String dia)
- {
- String lowerCase;
- switch ((lowerCase = dia.toLowerCase()).hashCode())
- {
- case -948818302:
- if (!lowerCase.equals("quarta")) {
- return 0;
- }
- return 4;
- case -948583818:
- if (!lowerCase.equals("quinta")) {
- return 0;
- }
- return 5;
- case -910017448:
- if (!lowerCase.equals("sabado")) {
- return 0;
- }
- return 7;
- case 109332819:
- if (!lowerCase.equals("sexta")) {
- return 0;
- }
- return 6;
- case 110250047:
- if (!lowerCase.equals("terca")) {
- return 0;
- }
- break;
- case 110254139:
- if (!lowerCase.equals("ter�a")) {
- return 0;
- }
- break;
- case 1837791503:
- if (!lowerCase.equals("domingo")) {
- return 0;
- }
- return 1;
- case 1973969579:
- if (!lowerCase.equals("segunda")) {
- return 0;
- }
- return 2;
- }
- return 3;
- }
- public static void checkTempo()
- {
- try
- {
- for (String s : LsFight.getInstance().getConfig().getStringList("AutoStart.Horarios"))
- {
- String[] a = s.split("-");
- String[] horario1 = null;
- String dia1;
- if (a.length == 2)
- {
- String dia1 = s.split("-")[0];
- horario1 = s.split("-")[1].split(":");
- }
- else
- {
- dia1 = "";
- horario1 = s.split("-")[0].split(":");
- }
- String dia2 = dia1;
- final String[] horario2 = horario1;
- Bukkit.getScheduler().scheduleSyncRepeatingTask(LsFight.getInstance(), new Runnable()
- {
- public void run()
- {
- 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])))
- {
- if ((AutoStart.data.getString("Entrada.") == null) || (AutoStart.data.getString("Saida.") == null) || (AutoStart.data.getString("Pos1.") == null) || (AutoStart.data.getString("Pos2.") == null))
- {
- Bukkit.getLogger().severe("[LsFight] Nao foi possivel iniciar o evento, entrada, saida, posicao 1 ou posicao 2 nao foi definida.");
- Bukkit.getLogger().severe("[LsFight] Nao foi possivel iniciar o evento, entrada, saida, posicao 1 ou posicao 2 nao foi definida.");
- Bukkit.getLogger().severe("[LsFight] Nao foi possivel iniciar o evento, entrada, saida, posicao 1 ou posicao 2 nao foi definida.");
- return;
- }
- if (!AutoStart.in)
- {
- FightUtils.iniciando(LsFight.getInstance().getConfig().getInt("Iniciando.NumeroDeAvisos"));
- AutoStart.in = true;
- }
- }
- else if ((Calendar.getInstance().get(11) == AutoStart.getHora(horario2[0])) && (Calendar.getInstance().get(12) == AutoStart.getMinuto(horario2[1])))
- {
- if ((AutoStart.data.getString("Entrada.") == null) || (AutoStart.data.getString("Saida.") == null) || (AutoStart.data.getString("Pos1.") == null) || (AutoStart.data.getString("Pos2.") == null))
- {
- Bukkit.getLogger().severe("[LsFight] Nao foi possivel iniciar o evento, entrada, saida, posicao 1 ou posicao 2 nao foi definida.");
- Bukkit.getLogger().severe("[LsFight] Nao foi possivel iniciar o evento, entrada, saida, posicao 1 ou posicao 2 nao foi definida.");
- Bukkit.getLogger().severe("[LsFight] Nao foi possivel iniciar o evento, entrada, saida, posicao 1 ou posicao 2 nao foi definida.");
- return;
- }
- if (!AutoStart.in)
- {
- FightUtils.iniciando(LsFight.getInstance().getConfig().getInt("Iniciando.NumeroDeAvisos"));
- AutoStart.in = true;
- }
- }
- }
- }, 0L, 200L);
- }
- }
- catch (Exception e)
- {
- Bukkit.getConsoleSender().sendMessage("�4[MVP] �cErro na configuracao dos horarios.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement