From 25ef3a0c816b84b3d070d2636f005e783d1f5972 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sat, 10 Mar 2018 23:59:31 +1100 Subject: [PATCH] Recover from invalid bstats configuration --- .../java/com/boydti/fawe/util/metrics/BStats.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/boydti/fawe/util/metrics/BStats.java b/core/src/main/java/com/boydti/fawe/util/metrics/BStats.java index b9c4f4fc..666de8a0 100644 --- a/core/src/main/java/com/boydti/fawe/util/metrics/BStats.java +++ b/core/src/main/java/com/boydti/fawe/util/metrics/BStats.java @@ -92,13 +92,18 @@ public class BStats implements Closeable { YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile); + if (config.isSet("serverUuid")) { + try { + serverUUID = UUID.fromString(config.getString("serverUuid")); + } catch (IllegalArgumentException ignore) {} + } // Check if the config file exists - if (!config.isSet("serverUuid")) { + if (serverUUID == null) { // Add default values config.addDefault("enabled", true); // Every server gets it's unique random id. - config.addDefault("serverUuid", UUID.randomUUID().toString()); + config.addDefault("serverUuid", (serverUUID = UUID.randomUUID()).toString()); // Should failed request be logged? config.addDefault("logFailedRequests", false); @@ -114,8 +119,6 @@ public class BStats implements Closeable { } catch (IOException ignored) { } } - // Load the data - serverUUID = UUID.fromString(config.getString("serverUuid")); if (usedMetricsClass != null) { // Already an instance of this class