diff options
author | kr45732 <52721908+kr45732@users.noreply.github.com> | 2023-06-08 10:00:04 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-08 16:00:04 +0200 |
commit | 8115922b37e375285c2a72dbdbb5d83fd942e27c (patch) | |
tree | e0d6cb5228493e8bb032465cbb2dfd95b4946e43 /src/main/kotlin | |
parent | a6fb7bfb97d313b665085a52a660150f1da26065 (diff) | |
download | NotEnoughUpdates-8115922b37e375285c2a72dbdbb5d83fd942e27c.tar.gz NotEnoughUpdates-8115922b37e375285c2a72dbdbb5d83fd942e27c.tar.bz2 NotEnoughUpdates-8115922b37e375285c2a72dbdbb5d83fd942e27c.zip |
PV Overhaul (#708)
Co-authored-by: Lulonaut <lulonaut@tutanota.de>
Diffstat (limited to 'src/main/kotlin')
3 files changed, 24 insertions, 29 deletions
diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/misc/PeekCommand.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/misc/PeekCommand.kt index 61fa6029..28d08048 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/misc/PeekCommand.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/misc/PeekCommand.kt @@ -23,7 +23,7 @@ import com.mojang.brigadier.arguments.StringArgumentType.string import io.github.moulberry.notenoughupdates.NotEnoughUpdates import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe import io.github.moulberry.notenoughupdates.events.RegisterBrigadierCommandEvent -import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer +import io.github.moulberry.notenoughupdates.profileviewer.SkyblockProfiles import io.github.moulberry.notenoughupdates.util.Utils import io.github.moulberry.notenoughupdates.util.brigadier.* import net.minecraft.client.Minecraft @@ -50,9 +50,9 @@ class PeekCommand { deleteReply("$YELLOW[PEEK] Getting player information...") - NotEnoughUpdates.profileViewer.getProfileByName( + NotEnoughUpdates.profileViewer.loadPlayerByName( name - ) { profile: ProfileViewer.Profile? -> + ) { profile: SkyblockProfiles? -> if (profile == null) { deleteReply("$RED[PEEK] Unknown player or the Hypixel API is down.") } else { @@ -72,29 +72,28 @@ class PeekCommand { return } val g = GRAY.toString() - val profileInfo = profile.getProfileInformation(null) + val profileInfo = profile.latestProfile.profileJson if (profileInfo == null) { future = executor.schedule(this, 200, TimeUnit.MILLISECONDS) return } var overallScore = 0f val isMe = name.equals("moulberry", ignoreCase = true) - val stats = profile.getStats(null) + val stats = profile.latestProfile.stats if (stats == null) { future = executor.schedule(this, 200, TimeUnit.MILLISECONDS) return } - val skyblockInfo = profile.getSkyblockInfo(null) + val skyblockInfo = profile.latestProfile.levelingInfo if (NotEnoughUpdates.INSTANCE.config.profileViewer.useSoopyNetworth) { deleteReply("$YELLOW[PEEK] Getting the player's Skyblock networth...") val countDownLatch = CountDownLatch(1) - profile.getSoopyNetworth(null, Runnable { countDownLatch.countDown() }) - try { //Wait for async network request + profile.latestProfile.getSoopyNetworth { countDownLatch.countDown() } + try { // Wait for async network request countDownLatch.await(10, TimeUnit.SECONDS) - } catch (e: InterruptedException) { - } + } catch (_: InterruptedException) {} - //Now it's waited for network request the data should be cached (accessed in nw section) + // Now it's waited for network request the data should be cached (accessed in nw section) } deleteReply( "$GREEN $STRIKETHROUGH-=-$RESET$GREEN ${ @@ -104,7 +103,7 @@ class PeekCommand { ) }'s Info $STRIKETHROUGH-=-" ) - if (skyblockInfo == null) { + if (skyblockInfo == null || !profile.latestProfile.skillsApiEnabled()) { Utils.addChatMessage(YELLOW.toString() + "Skills API disabled!") } else { var totalSkillLVL = 0f @@ -216,11 +215,10 @@ class PeekCommand { ), 0f ) val networth = if (NotEnoughUpdates.INSTANCE.config.profileViewer.useSoopyNetworth) { - val nwData = - profile.getSoopyNetworth(null, Runnable {}) - nwData?.total ?: -2L + val nwData = profile.latestProfile.getSoopyNetworth {} + nwData?.networth ?: -2L } else { - profile.getNetWorth(null) + profile.latestProfile.networth } val money = Math.max(bankBalance + purseBalance, networth.toFloat()) @@ -245,16 +243,14 @@ class PeekCommand { val activePet = Utils.getElementAsString( Utils.getElement( - profile.getPetsInfo( - null - ), "active_pet.type" + profile.latestProfile.petsInfo, "active_pet.type" ), "None Active" ) val activePetTier = Utils.getElementAsString( Utils.getElement( - profile.getPetsInfo(null), + profile.latestProfile.petsInfo, "active_pet.tier" ), "UNKNOWN" ) diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/misc/ProfileViewerCommands.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/misc/ProfileViewerCommands.kt index 8a2763f7..da97f0d2 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/misc/ProfileViewerCommands.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/misc/ProfileViewerCommands.kt @@ -46,7 +46,7 @@ class ProfileViewerCommands { return } - NotEnoughUpdates.profileViewer.getProfileByName(name) { profile -> + NotEnoughUpdates.profileViewer.loadPlayerByName(name) { profile -> if (profile == null) { reply("${RED}Invalid player name/API key. Maybe the API is down? Try /api new.") } else { diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscgui/pricegraph/GuiPriceGraph.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscgui/pricegraph/GuiPriceGraph.kt index 0fe6d843..af2b9c2a 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscgui/pricegraph/GuiPriceGraph.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscgui/pricegraph/GuiPriceGraph.kt @@ -20,6 +20,7 @@ package io.github.moulberry.notenoughupdates.miscgui.pricegraph import io.github.moulberry.notenoughupdates.NotEnoughUpdates +import io.github.moulberry.notenoughupdates.core.util.StringUtils import io.github.moulberry.notenoughupdates.util.SpecialColour import io.github.moulberry.notenoughupdates.util.Utils import io.github.moulberry.notenoughupdates.util.roundToDecimals @@ -31,7 +32,6 @@ import net.minecraft.util.EnumChatFormatting import net.minecraft.util.ResourceLocation import org.lwjgl.opengl.GL11 import java.text.DecimalFormat -import java.text.NumberFormat import java.text.SimpleDateFormat import java.time.Duration import java.time.Instant @@ -42,7 +42,6 @@ import kotlin.math.abs private const val X_SIZE = 364 private const val Y_SIZE = 215 private val dateFormat = SimpleDateFormat("'§b'd MMMMM yyyy '§eat§b' HH:mm") -private val numberFormat = NumberFormat.getInstance() private val config = NotEnoughUpdates.INSTANCE.config class GuiPriceGraph(itemId: String) : GuiScreen() { @@ -248,29 +247,29 @@ class GuiPriceGraph(itemId: String) : GuiScreen() { if (closestPoint.value.sellPrice == null) { text.add( "${EnumChatFormatting.YELLOW}${EnumChatFormatting.BOLD}Lowest BIN: ${EnumChatFormatting.GOLD}" + - "${EnumChatFormatting.BOLD}${numberFormat.format(closestPoint.value.buyPrice)}" + "${EnumChatFormatting.BOLD}${StringUtils.formatNumber(closestPoint.value.buyPrice)}" ) if (config.ahGraph.movingAverages && buyMovingAverage[x] != null) text.add( "${EnumChatFormatting.YELLOW}${EnumChatFormatting.BOLD}Lowest BIN Moving Average: ${EnumChatFormatting.GOLD}" + - "${EnumChatFormatting.BOLD}${numberFormat.format(buyMovingAverage[x])}" + "${EnumChatFormatting.BOLD}${StringUtils.formatNumber(buyMovingAverage[x])}" ) } else { text.add( "${EnumChatFormatting.YELLOW}${EnumChatFormatting.BOLD}Bazaar Insta-Buy: ${EnumChatFormatting.GOLD}" + - "${EnumChatFormatting.BOLD}${numberFormat.format(closestPoint.value.buyPrice)}" + "${EnumChatFormatting.BOLD}${StringUtils.formatNumber(closestPoint.value.buyPrice)}" ) text.add( "${EnumChatFormatting.YELLOW}${EnumChatFormatting.BOLD}Bazaar Insta-Sell: ${EnumChatFormatting.GOLD}" + - "${EnumChatFormatting.BOLD}${numberFormat.format(closestPoint.value.sellPrice)}" + "${EnumChatFormatting.BOLD}${StringUtils.formatNumber(closestPoint.value.sellPrice)}" ) if (config.ahGraph.movingAverages) { if (buyMovingAverage[x] != null) text.add( "${EnumChatFormatting.YELLOW}${EnumChatFormatting.BOLD}Bazaar Insta-Buy Moving Average: ${EnumChatFormatting.GOLD}${EnumChatFormatting.BOLD}" + - numberFormat.format(buyMovingAverage[x]) + StringUtils.formatNumber(buyMovingAverage[x]) ) if (sellMovingAverage[x] != null) text.add( "${EnumChatFormatting.YELLOW}${EnumChatFormatting.BOLD}Bazaar Insta-Sell Moving Average: ${EnumChatFormatting.GOLD}${EnumChatFormatting.BOLD}" + - numberFormat.format(sellMovingAverage[x]) + StringUtils.formatNumber(sellMovingAverage[x]) ) } } |