From 21f613bbe7aa28486879a0f47b3615ce739e38ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beatrice=20Dellac=C3=A0?= Date: Sat, 11 Feb 2023 21:05:54 +0100 Subject: [PATCH] Improve code quality --- src/main/java/wtf/beatrice/hubthat/HubThat.java | 3 +++ src/main/java/wtf/beatrice/hubthat/utils/ConfigEntry.java | 5 ----- .../wtf/beatrice/hubthat/utils/metrics/UpdateChecker.java | 8 +++----- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/main/java/wtf/beatrice/hubthat/HubThat.java b/src/main/java/wtf/beatrice/hubthat/HubThat.java index 86d6fb5..9471503 100644 --- a/src/main/java/wtf/beatrice/hubthat/HubThat.java +++ b/src/main/java/wtf/beatrice/hubthat/HubThat.java @@ -54,7 +54,10 @@ public class HubThat extends JavaPlugin // Initialize command classes. debugger.sendDebugMessage(Level.INFO, "Loading classes..."); + FileUtils fileUtilsInstance = new FileUtils(this); + // todo: ^ this is bad, utils should not be instantiated. + HubThatCommand hubThatCommandInstance = new HubThatCommand(this); HubCommand hubCommandInstance = new HubCommand(this); SpawnCommand spawnCommandInstance = new SpawnCommand(this); diff --git a/src/main/java/wtf/beatrice/hubthat/utils/ConfigEntry.java b/src/main/java/wtf/beatrice/hubthat/utils/ConfigEntry.java index 17ec6f9..b57439d 100644 --- a/src/main/java/wtf/beatrice/hubthat/utils/ConfigEntry.java +++ b/src/main/java/wtf/beatrice/hubthat/utils/ConfigEntry.java @@ -13,19 +13,14 @@ public enum ConfigEntry MOVEMENT_DETECTION_ENABLED("movement-detection.enable"), GAMEMODE_SET_ON_JOIN("gamemode.set-on-join"), - GAMEMODE("gamemode.mode"), TELEPORTATION_RESPAWN_HANDLER("teleportation.respawn-handler"), - TELEPORTATION_TP_HUB_ON_JOIN("teleportation.teleport-to-hub-on-join"), - TELEPORTATION_TP_MESSAGE_ON_JOIN("teleportation.send-tp-message-on-join"), - TELEPORTATION_TP_HUB_ON_RESPAWN("teleportation.teleport-to-hub-on-respawn"), MULTIVERSE_BYPASS("settings.multiverse-bypass"), - INVISIBILITY_FIX("settings.fix-invisible-after-tp"), ; diff --git a/src/main/java/wtf/beatrice/hubthat/utils/metrics/UpdateChecker.java b/src/main/java/wtf/beatrice/hubthat/utils/metrics/UpdateChecker.java index 9c9e513..07891d3 100644 --- a/src/main/java/wtf/beatrice/hubthat/utils/metrics/UpdateChecker.java +++ b/src/main/java/wtf/beatrice/hubthat/utils/metrics/UpdateChecker.java @@ -87,8 +87,7 @@ public class UpdateChecker implements Runnable } catch (IOException e) { - - setAndSendErrorCode("null json", console); + setAndSendErrorCode(e.getMessage(), console); return; } @@ -97,11 +96,10 @@ public class UpdateChecker implements Runnable JsonObject json = (JsonObject)jsonParser.parse(new InputStreamReader(jsonIS, StandardCharsets.UTF_8)); // Close the input stream... - /*try { + try { jsonIS.close(); } catch (IOException ignored) - { - }*/ + {} // Check if the "version" String is present... newVersion = null;