Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.genuscraft.hubcore.recompensas;
- import com.genuscraft.hubcore.Main;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.entity.Player;
- public class CooldownRecompensas {
- private Main plugin;
- public CooldownRecompensas(Main plugin){
- this.plugin = plugin;
- }
- public String getCooldown(Player jugador){
- FileConfiguration datarewards = plugin.getDataRewards();
- FileConfiguration recompensas = plugin.getRecompensas();
- for(String key : recompensas.getConfigurationSection("Rewards").getKeys(false)){
- String pathtime = "Recompensas."+jugador.getUniqueId()+"."+key;
- int timesecondsrecompensas = recompensas.getInt("Rewards."+key+".cooldown-seconds");
- if(datarewards.contains(pathtime)){
- String timecooldownString = datarewards.getString(pathtime);
- long timecooldown = Long.valueOf(timecooldownString);
- long millis = System.currentTimeMillis();
- long cooldown = timesecondsrecompensas;
- long cooldownmil = cooldown*1000;
- long wait = millis - timecooldown;
- long waitDiv = wait/1000;
- long waittotalseg = cooldown - waitDiv;
- long waittotalmin = waittotalseg/60;
- long waittotalhour = waittotalmin/60;
- if(((timecooldown + cooldownmil) > millis) && (timecooldown != 0)){
- if(waittotalseg > 59){
- waittotalseg = waittotalseg - 60*waittotalmin;
- }
- String time = "";
- if(waittotalseg != 0){
- time = waittotalseg+"s";
- }
- if(waittotalmin > 59){
- waittotalmin = waittotalmin - 60*waittotalhour;
- }
- if(waittotalmin > 0){
- time = waittotalmin+"min"+" "+time;
- }
- if(waittotalhour > 0){
- time = waittotalhour+ "h"+" " + time;
- }
- return time;
- }else{
- return "-1";
- }
- }else{
- return "-1";
- }
- }
- return "";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement