From 0e7608c2ab39f9fd04edc84bd6e7c47df704380b Mon Sep 17 00:00:00 2001 From: Patbox Date: Sat, 11 Nov 2023 10:21:27 +0100 Subject: [PATCH] Try catch --- .../status/ServerPerformanceIntegration.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/xyz/nucleoid/extras/integrations/status/ServerPerformanceIntegration.java b/src/main/java/xyz/nucleoid/extras/integrations/status/ServerPerformanceIntegration.java index f4f1e9d..ba15501 100644 --- a/src/main/java/xyz/nucleoid/extras/integrations/status/ServerPerformanceIntegration.java +++ b/src/main/java/xyz/nucleoid/extras/integrations/status/ServerPerformanceIntegration.java @@ -70,11 +70,15 @@ private void tick(MinecraftServer server) { } private static float getAverageTickMs(PerformanceLog log) { - long total = 0; - for (int index = 0; index < log.size(); index++) { - total += log.get(index); + try { + long total = 0; + for (int index = 0; index < log.size(); index++) { + total += log.get(index); + } + double averageTickNs = (double) total / log.size(); + return (float) (averageTickNs / 1000000.0); + } catch (Throwable e) { + return 0; } - double averageTickNs = (double) total / log.size(); - return (float) (averageTickNs / 1000000.0); } }