From b944188297014cf0bbd5ebcb4c124b2ca77a5cee Mon Sep 17 00:00:00 2001 From: Kevinthegreat <92656833+kevinthegreat1@users.noreply.github.com> Date: Sun, 29 Oct 2023 02:56:50 -0400 Subject: Refactor TooltipInfoType#run --- .../skyblock/item/tooltip/TooltipInfoType.java | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'src/main/java/de') diff --git a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipInfoType.java b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipInfoType.java index b786f4c1..086fcb00 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipInfoType.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/item/tooltip/TooltipInfoType.java @@ -82,10 +82,6 @@ public enum TooltipInfoType implements Runnable { return data; } - public void setData(JsonObject data) { - this.data = data; - } - /** * Checks if the data has the given member name and sends a warning message if data is null. * @@ -135,18 +131,13 @@ public enum TooltipInfoType implements Runnable { @Override public void run() { try { - if (this.cacheable) { + if (cacheable) { HttpHeaders headers = Http.sendHeadRequest(address); - long combinedHash = Http.getEtag(headers).hashCode() + Http.getLastModified(headers).hashCode(); - - switch (this) { - case NPC, MOTES, MUSEUM, COLOR: - if (this.hash == combinedHash) return; - else this.hash = combinedHash; - } + long hash = Http.getEtag(headers).hashCode() + Http.getLastModified(headers).hashCode(); + if (this.hash == hash) return; + else this.hash = hash; } - - setData(SkyblockerMod.GSON.fromJson(Http.sendGetRequest(address), JsonObject.class)); + data = SkyblockerMod.GSON.fromJson(Http.sendGetRequest(address), JsonObject.class); } catch (Exception e) { ItemTooltip.LOGGER.warn("[Skyblocker] Failed to download " + this + " prices!", e); } -- cgit