Advertisement
Guest User

foobar

a guest
Nov 7th, 2016
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.     return Integer.parseInt(hora);
  19.   }
  20.  
  21.   private static int getMinuto(String minuto) {
  22.     return Integer.parseInt(minuto);
  23.   }
  24.  
  25.   private static int getDia(String dia)
  26.   {
  27.     String lowerCase;
  28.     switch ((lowerCase = dia.toLowerCase()).hashCode())
  29.     {
  30.     case -948818302:
  31.       if (!lowerCase.equals("quarta")) {
  32.         return 0;
  33.       }
  34.       return 4;
  35.     case -948583818:
  36.       if (!lowerCase.equals("quinta")) {
  37.         return 0;
  38.       }
  39.       return 5;
  40.     case -910017448:
  41.       if (!lowerCase.equals("sabado")) {
  42.         return 0;
  43.       }
  44.       return 7;
  45.     case 109332819:
  46.       if (!lowerCase.equals("sexta")) {
  47.         return 0;
  48.       }
  49.       return 6;
  50.     case 110250047:
  51.       if (!lowerCase.equals("terca")) {
  52.         return 0;
  53.       }
  54.       break;
  55.     case 110254139:
  56.       if (!lowerCase.equals("ter�a")) {
  57.         return 0;
  58.       }
  59.       break;
  60.     case 1837791503:
  61.       if (!lowerCase.equals("domingo")) {
  62.         return 0;
  63.       }
  64.       return 1;
  65.     case 1973969579:
  66.       if (!lowerCase.equals("segunda")) {
  67.         return 0;
  68.       }
  69.       return 2;
  70.     }
  71.     return 3;
  72.   }
  73.  
  74.   public static void checkTempo()
  75.   {
  76.     try
  77.     {
  78.       for (String s : LsFight.getInstance().getConfig().getStringList("AutoStart.Horarios"))
  79.       {
  80.         String[] a = s.split("-");
  81.         String[] horario1 = null;
  82.         String dia1;
  83.         if (a.length == 2)
  84.         {
  85.           String dia1 = s.split("-")[0];
  86.           horario1 = s.split("-")[1].split(":");
  87.         }
  88.         else
  89.         {
  90.           dia1 = "";
  91.           horario1 = s.split("-")[0].split(":");
  92.         }
  93.         String dia2 = dia1;
  94.         final String[] horario2 = horario1;
  95.         Bukkit.getScheduler().scheduleSyncRepeatingTask(LsFight.getInstance(), new Runnable()
  96.         {
  97.           public void run()
  98.           {
  99.             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])))
  100.             {
  101.               if ((AutoStart.data.getString("Entrada.") == null) || (AutoStart.data.getString("Saida.") == null) || (AutoStart.data.getString("Pos1.") == null) || (AutoStart.data.getString("Pos2.") == null))
  102.               {
  103.                 Bukkit.getLogger().severe("[LsFight] Nao foi possivel iniciar o evento, entrada, saida, posicao 1 ou posicao 2 nao foi definida.");
  104.                 Bukkit.getLogger().severe("[LsFight] Nao foi possivel iniciar o evento, entrada, saida, posicao 1 ou posicao 2 nao foi definida.");
  105.                 Bukkit.getLogger().severe("[LsFight] Nao foi possivel iniciar o evento, entrada, saida, posicao 1 ou posicao 2 nao foi definida.");
  106.                 return;
  107.               }
  108.               if (!AutoStart.in)
  109.               {
  110.                 FightUtils.iniciando(LsFight.getInstance().getConfig().getInt("Iniciando.NumeroDeAvisos"));
  111.                 AutoStart.in = true;
  112.               }
  113.             }
  114.             else if ((Calendar.getInstance().get(11) == AutoStart.getHora(horario2[0])) && (Calendar.getInstance().get(12) == AutoStart.getMinuto(horario2[1])))
  115.             {
  116.               if ((AutoStart.data.getString("Entrada.") == null) || (AutoStart.data.getString("Saida.") == null) || (AutoStart.data.getString("Pos1.") == null) || (AutoStart.data.getString("Pos2.") == null))
  117.               {
  118.                 Bukkit.getLogger().severe("[LsFight] Nao foi possivel iniciar o evento, entrada, saida, posicao 1 ou posicao 2 nao foi definida.");
  119.                 Bukkit.getLogger().severe("[LsFight] Nao foi possivel iniciar o evento, entrada, saida, posicao 1 ou posicao 2 nao foi definida.");
  120.                 Bukkit.getLogger().severe("[LsFight] Nao foi possivel iniciar o evento, entrada, saida, posicao 1 ou posicao 2 nao foi definida.");
  121.                 return;
  122.               }
  123.               if (!AutoStart.in)
  124.               {
  125.                 FightUtils.iniciando(LsFight.getInstance().getConfig().getInt("Iniciando.NumeroDeAvisos"));
  126.                 AutoStart.in = true;
  127.               }
  128.             }
  129.           }
  130.         }, 0L, 200L);
  131.       }
  132.     }
  133.     catch (Exception e)
  134.     {
  135.       Bukkit.getConsoleSender().sendMessage("�4[MVP] �cErro na configuracao dos horarios.");
  136.     }
  137.   }
  138. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement