From 6ca951d739913486e9a345be47ab467bad8e97c3 Mon Sep 17 00:00:00 2001 From: Lulonaut <67191924+Lulonaut@users.noreply.github.com> Date: Wed, 13 Apr 2022 07:53:52 +0200 Subject: Crimson Essence support (#110) * jani1 * update bingo more often * crimson support * move method to Utils * remove debug prints * fix single items * gray items * improvements better variable names fix behavior from 10 to 15 stars use EnumChatFormatting instead of the color code directly * fix dungeonize cost * remove master stars check --- .../profileviewer/ProfileViewer.java | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java index b8f8554e..22656b1a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/profileviewer/ProfileViewer.java @@ -20,7 +20,13 @@ import net.minecraft.util.EnumChatFormatting; import javax.annotation.Nullable; import java.io.ByteArrayInputStream; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.Base64; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; import java.util.regex.Matcher; @@ -477,12 +483,13 @@ public class ProfileViewer { } public JsonObject getBingoInformation() { - if (bingoInformation != null) return bingoInformation; - if (updatingBingoInfo.get()) return null; - long currentTime = System.currentTimeMillis(); - if (currentTime - lastBingoInfoState < 15 * 1000) return null; + if (bingoInformation != null && currentTime - lastBingoInfoState < 15 * 1000) return bingoInformation; + if (updatingBingoInfo.get() && bingoInformation != null) return bingoInformation; + if (updatingBingoInfo.get() && bingoInformation == null) return null; + lastBingoInfoState = currentTime; + updatingBingoInfo.set(true); HashMap args = new HashMap<>(); args.put("uuid", "" + uuid); @@ -492,15 +499,15 @@ public class ProfileViewer { args, jsonObject -> { if (jsonObject == null) return; - updatingBingoInfo.set(false); if (jsonObject.has("success") && jsonObject.get("success").getAsBoolean()) { bingoInformation = jsonObject; } else { bingoInformation = null; } + updatingBingoInfo.set(false); }, () -> updatingBingoInfo.set(false) ); - return null; + return bingoInformation != null ? bingoInformation : null; } public long getNetWorth(String profileId) { -- cgit