Advertisement
RazorPlay01

Timer

May 13th, 2022
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. String pathtime = "Players."+jugador.getUniqueId()+".cooldown-recompensa"; 
  2. if(config.contains(pathtime)){
  3.     String timecooldownString = config.getString(pathtime);
  4.     long timecooldown = Long.valueOf(timecooldownString);
  5.     long millis = System.currentTimeMillis();
  6.         long cooldown = 100; //En Segundos
  7.         long cooldownmil = cooldown*1000;
  8.        
  9.         long espera = millis - timecooldown;
  10.         long esperaDiv = espera/1000;
  11.         long esperatotalseg = cooldown - esperaDiv;
  12.         long esperatotalmin = esperatotalseg/60;
  13.         long esperatotalhour = esperatotalmin/60;
  14.         if(((timecooldown + cooldownmil) > millis) && (timecooldown != 0)){                
  15.            if(esperatotalseg > 59){
  16.                esperatotalseg = esperatotalseg - 60*esperatotalmin;
  17.            }
  18.            String time = "";
  19.            if(esperatotalseg != 0){
  20.               time = esperatotalseg+"s";
  21.            }
  22.                            
  23.            if(esperatotalmin > 59){
  24.                esperatotalmin = esperatotalmin - 60*esperatotalhour;
  25.            }   
  26.            if(esperatotalmin > 0){
  27.                time = esperatotalmin+"min"+" "+time;
  28.            }
  29.            
  30.            if(esperatotalhour > 0){
  31.                time = esperatotalhour+ "h"+" " + time;
  32.            }
  33.            
  34.            //Aun no se termina el cooldown
  35.            jugador.sendMessage("Puedes reclamar otra recompensa diaria dentro de "+time);
  36.         }else{
  37.             //Ya se termino el cooldown
  38.             jugador.sendMessage("Acabas de recibir la recompensa diaria nuevamente");
  39.         config.set(pathtime, millis);
  40.         plugin.saveConfig();
  41.         }
  42. }else{
  43.     //Usa el comando por primera vez, ya que no existe el path en la config
  44.     jugador.sendMessage("Acabas de recibir la recompensa diaria");
  45.     long millis = System.currentTimeMillis();  
  46.     config.set(pathtime, millis);
  47.     plugin.saveConfig();
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement