From 179152c2611718f309427fd19b531d32a1290427 Mon Sep 17 00:00:00 2001 From: lookshe Date: Mon, 4 Mar 2024 09:45:43 +0100 Subject: [PATCH] fix #967 (#968) --- src/main/java/mServer/Main.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/mServer/Main.java b/src/main/java/mServer/Main.java index f5cf3c242..82e6920c6 100644 --- a/src/main/java/mServer/Main.java +++ b/src/main/java/mServer/Main.java @@ -29,6 +29,9 @@ import mServer.tool.MserverDatumZeit; import mServer.tool.MserverLog; +import java.time.LocalDateTime; +import java.time.temporal.ChronoUnit; + public class Main { public Main() { @@ -88,11 +91,15 @@ public static void main(String[] args) { } private static void runServer(String[] ar) throws InterruptedException { + LocalDateTime beforeRun = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS); while (new MServer(ar).starten()) { - long timeToSleep = (MserverDatumZeit.getSecondsUntilNextDay() + 120) * 1000; // 0:02 - MserverLog.systemMeldung("Schlafenlegen bis zum nächsten Tag (" + timeToSleep + "ms)"); - Thread.sleep(timeToSleep); - MserverLog.systemMeldung("Neustart der Suche"); + if (!LocalDateTime.now().truncatedTo(ChronoUnit.DAYS).isAfter(beforeRun)) { // do not sleep if day changed + long timeToSleep = (MserverDatumZeit.getSecondsUntilNextDay() + 120) * 1000; // 0:02 + MserverLog.systemMeldung("Schlafenlegen bis zum nächsten Tag (" + timeToSleep + "ms)"); + Thread.sleep(timeToSleep); + MserverLog.systemMeldung("Neustart der Suche"); + } + beforeRun = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS); } }