From 8b97ea038311c0bf230bb6f25ce23beb01ad47a6 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 17 Jan 2023 18:13:32 +0100 Subject: [PATCH] Fix LaufbauState Signed-off-by: yoyosource --- .../features/slaves/laufbau/states/LaufbauState.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/LaufbauState.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/LaufbauState.java index 346332fe..88041527 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/LaufbauState.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/LaufbauState.java @@ -36,6 +36,13 @@ public interface LaufbauState { default String eta(Player p, long start, int done, int total) { if (total == 0) return ""; long elapsed = System.currentTimeMillis() - start; - return LocalTime.ofNanoOfDay((long) (elapsed / (done / (double) total) - elapsed) * 1000000).format(DateTimeFormatter.ofPattern(BauSystem.MESSAGE.parse("TIME", p))); + long eta = (long) (elapsed / (done / (double) total) - elapsed); + if (eta > 86399999999999L) { + return LocalTime.ofNanoOfDay(86399999999999L).format(DateTimeFormatter.ofPattern(BauSystem.MESSAGE.parse("TIME", p))); + } + if (eta < 0) { + return LocalTime.ofNanoOfDay(0).format(DateTimeFormatter.ofPattern(BauSystem.MESSAGE.parse("TIME", p))); + } + return LocalTime.ofNanoOfDay(eta * 1000000).format(DateTimeFormatter.ofPattern(BauSystem.MESSAGE.parse("TIME", p))); } }