Advertisement
Guest User

CooldownRecompensas.java

a guest
Jan 4th, 2021
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. package com.genuscraft.hubcore.recompensas;
  2.  
  3. import com.genuscraft.hubcore.Main;
  4. import org.bukkit.configuration.file.FileConfiguration;
  5. import org.bukkit.entity.Player;
  6.  
  7. public class CooldownRecompensas {
  8.  
  9. private Main plugin;
  10.  
  11. public CooldownRecompensas(Main plugin){
  12. this.plugin = plugin;
  13. }
  14.  
  15. public String getCooldown(Player jugador){
  16.  
  17. FileConfiguration datarewards = plugin.getDataRewards();
  18. FileConfiguration recompensas = plugin.getRecompensas();
  19.  
  20. for(String key : recompensas.getConfigurationSection("Rewards").getKeys(false)){
  21. String pathtime = "Recompensas."+jugador.getUniqueId()+"."+key;
  22.  
  23. int timesecondsrecompensas = recompensas.getInt("Rewards."+key+".cooldown-seconds");
  24. if(datarewards.contains(pathtime)){
  25. String timecooldownString = datarewards.getString(pathtime);
  26. long timecooldown = Long.valueOf(timecooldownString);
  27. long millis = System.currentTimeMillis();
  28. long cooldown = timesecondsrecompensas;
  29. long cooldownmil = cooldown*1000;
  30.  
  31. long wait = millis - timecooldown;
  32. long waitDiv = wait/1000;
  33. long waittotalseg = cooldown - waitDiv;
  34. long waittotalmin = waittotalseg/60;
  35. long waittotalhour = waittotalmin/60;
  36. if(((timecooldown + cooldownmil) > millis) && (timecooldown != 0)){
  37. if(waittotalseg > 59){
  38. waittotalseg = waittotalseg - 60*waittotalmin;
  39. }
  40. String time = "";
  41. if(waittotalseg != 0){
  42. time = waittotalseg+"s";
  43. }
  44.  
  45. if(waittotalmin > 59){
  46. waittotalmin = waittotalmin - 60*waittotalhour;
  47. }
  48. if(waittotalmin > 0){
  49. time = waittotalmin+"min"+" "+time;
  50. }
  51.  
  52. if(waittotalhour > 0){
  53. time = waittotalhour+ "h"+" " + time;
  54. }
  55. return time;
  56. }else{
  57. return "-1";
  58. }
  59. }else{
  60. return "-1";
  61. }
  62. }
  63. return "";
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement