Sync save time less dependent on tick time
This commit is contained in:
1 parent
628dd2827e
commit
329d5993fe
4 files changed
+26
-12
No files matched your search
@@ -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() {
|
||||
|
||||
Reference in new issue
Block a user