Renamed and fixed function that retrieves the next execution time
This commit is contained in:
parent
329d5993fe
commit
cea765e157
|
|
@ -30,7 +30,7 @@ public class LogInOut extends BukkitRunnable {
|
|||
map = loadFile(file);
|
||||
else
|
||||
map = new HashMap<>();
|
||||
this.nextExecution = Utilities.getNextXMinuteTime(Config.LOG_TIME);
|
||||
this.nextExecution = Utilities.getMillisTillNextX(Config.LOG_TIME);
|
||||
}
|
||||
|
||||
public void log(String material, double cost) {
|
||||
|
|
@ -65,7 +65,7 @@ public class LogInOut extends BukkitRunnable {
|
|||
return;
|
||||
if (System.currentTimeMillis() < nextExecution)
|
||||
return;
|
||||
nextExecution = Utilities.getNextXMinuteTime(Config.LOG_TIME);
|
||||
nextExecution = Utilities.getMillisTillNextX(Config.LOG_TIME);
|
||||
int new_day = Calendar.getInstance().get(Calendar.DAY_OF_YEAR);
|
||||
if (!file.exists()) {
|
||||
boolean success = false;
|
||||
|
|
|
|||
|
|
@ -9,14 +9,14 @@ public class SaveTask extends BukkitRunnable {
|
|||
private long nextExecution;
|
||||
|
||||
public SaveTask() {
|
||||
this.nextExecution = Utilities.getNextXMinuteTime(Config.SAVE_TIME);
|
||||
this.nextExecution = Utilities.getMillisTillNextX(Config.SAVE_TIME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (System.currentTimeMillis() < nextExecution)
|
||||
return;
|
||||
nextExecution = Utilities.getNextXMinuteTime(Config.SAVE_TIME);
|
||||
nextExecution = Utilities.getMillisTillNextX(Config.SAVE_TIME);
|
||||
if (Config.DEBUG)
|
||||
Logger.info("Syncing users.");
|
||||
EconUser.getEconUsers().forEach(econUser -> {
|
||||
|
|
|
|||
|
|
@ -147,9 +147,9 @@ public class Utilities {
|
|||
return str.substring(0, 1).toUpperCase() + str.substring(1);
|
||||
}
|
||||
|
||||
public static long getNextXMinuteTime(int minutes) {
|
||||
public static long getMillisTillNextX(int minutes) {
|
||||
long millis = TimeUnit.MINUTES.toMillis(minutes);
|
||||
long currentMillis = System.currentTimeMillis();
|
||||
return currentMillis + (currentMillis - (currentMillis % millis));
|
||||
return currentMillis + (millis - (currentMillis % millis));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user