Skip to content

Commit

Permalink
Refactor TooltipInfoType#run
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinthegreat1 committed Oct 29, 2023
1 parent 13e7b46 commit 83a5c0f
Showing 1 changed file with 5 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,6 @@ public JsonObject getData() {
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.
*
Expand Down Expand Up @@ -135,18 +131,13 @@ public void download(List<CompletableFuture<Void>> futureList) {
@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);
}
Expand Down

0 comments on commit 83a5c0f

Please sign in to comment.