Sync save time less dependent on tick time

This commit is contained in:
auto committed 2023-04-23 21:24:16 +02:00
1 parent 628dd2827e
commit 329d5993fe
4 files changed
+26 -12

No files matched your search

+4 -11
View File
@@ -18,8 +18,6 @@ import org.bukkit.Bukkit;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.concurrent.TimeUnit;
public class VillagerUI extends JavaPlugin {
public static VillagerUI instance;
@@ -73,17 +71,12 @@ public class VillagerUI extends JavaPlugin {
private void scheduleTasks() {
new SaveTask().runTaskTimerAsynchronously(
this,
getSecondsToNextXMinutes(Config.SAVE_TIME) * 20,
TimeUnit.MINUTES.toSeconds(Config.SAVE_TIME) * 60 * 20L);
0,
20);
logInOut.runTaskTimerAsynchronously(
this,
getSecondsToNextXMinutes(Config.LOG_TIME) * 20,
TimeUnit.MINUTES.toSeconds(Config.LOG_TIME) * 20L);
}
public static long getSecondsToNextXMinutes(int minutes) {
long seconds = TimeUnit.MINUTES.toSeconds(minutes);
return seconds - (TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()) % seconds);
0,
20);
}
private void registerEvents() {