From 77697fc96ada428087f8abc2022ddb82df307d20 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sun, 1 Jan 2023 17:30:29 +0100 Subject: 0.13.1 color fix --- CHANGELOG.md | 5 +++++ build.gradle.kts | 2 +- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java | 2 +- .../java/at/hannibal2/skyhanni/features/dungeon/DungeonLevelColor.kt | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ff538037..7e3818601 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # SkyHanni - Change Log +## Version 0.13.1 + +### Fixes ++ Dungeon level color fixed wrong colors. + ## Version 0.13 ### Features diff --git a/build.gradle.kts b/build.gradle.kts index ad8158481..398adb850 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,7 +10,7 @@ plugins { } group = "at.hannibal2.skyhanni" -version = "0.13" +version = "0.13.1" // Toolchains: java { diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index eccfc78c9..fa5cc233f 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -62,7 +62,7 @@ import java.util.List; public class SkyHanniMod { public static final String MODID = "skyhanni"; - public static final String VERSION = "0.13"; + public static final String VERSION = "0.13.1"; public static Features feature; diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLevelColor.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLevelColor.kt index 796f93ef4..740296f47 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLevelColor.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonLevelColor.kt @@ -45,7 +45,7 @@ class DungeonLevelColor { if (level >= 50) return "§c§l" if (level >= 45) return "§c" if (level >= 40) return "§d" - if (level >= 35) return "§b" + if (level >= 35) return "§6" if (level >= 30) return "§5" if (level >= 25) return "§9" if (level >= 20) return "§a" -- cgit From 267ef5a027c6c67f91e52cbf52a0aacb550d2378 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 6 Jan 2023 23:12:44 +0100 Subject: debug command logic and console filter changes --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java | 2 -- .../at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt | 2 +- .../hannibal2/skyhanni/test/command/CopyItemCommand.kt | 1 - src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt | 9 ++++++++- .../java/at/hannibal2/skyhanni/utils/LorenzUtils.kt | 17 ++++++++++++----- .../hannibal2/skyhanni/utils/MinecraftConsoleFilter.kt | 10 +++++++--- 6 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index fa5cc233f..a88ef4696 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -186,11 +186,9 @@ public class SkyHanniMod { private void registerEvent(Object object) { listenerClasses.add(object); String simpleName = object.getClass().getSimpleName(); - consoleLog("SkyHanni registering '" + simpleName + "'"); long start = System.currentTimeMillis(); MinecraftForge.EVENT_BUS.register(object); long duration = System.currentTimeMillis() - start; - consoleLog("Done after " + duration + " ms!"); } public static GuiScreen screenToOpen = null; diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt index c2c8bcb18..857305c27 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarApi.kt @@ -8,7 +8,7 @@ import net.minecraft.item.ItemStack class BazaarApi { companion object { - private val bazaarMap = mutableMapOf() + val bazaarMap = mutableMapOf() fun isBazaarInventory(inventoryName: String): Boolean { if (inventoryName.contains(" ➜ ") && !inventoryName.contains("Museum")) return true diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt index 5395dbf36..92275ed69 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/CopyItemCommand.kt @@ -38,7 +38,6 @@ object CopyItemCommand { val string = resultList.joinToString("\n") OSUtils.copyToClipboard(string) - LorenzUtils.debug("item info printed!") LorenzUtils.chat("§e[SkyHanni] item info copied into the clipboard!") } catch (_: Throwable) { LorenzUtils.chat("§c[SkyHanni] No item in hand!") diff --git a/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt b/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt index 5584da0fe..908d8b810 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/APIUtil.kt @@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.utils import at.hannibal2.skyhanni.SkyHanniMod import com.google.gson.JsonObject import com.google.gson.JsonParser +import com.google.gson.stream.MalformedJsonException import org.apache.http.client.config.RequestConfig import org.apache.http.client.methods.HttpGet import org.apache.http.impl.client.HttpClientBuilder @@ -40,7 +41,13 @@ object APIUtil { val entity = response.entity if (entity != null) { val retSrc = EntityUtils.toString(entity) - return parser.parse(retSrc) as JsonObject + try { + return parser.parse(retSrc) as JsonObject + } catch (e: MalformedJsonException) { + LorenzUtils.error("MalformedJsonException!") + println("MalformedJsonException at '$urlString'") + e.printStackTrace() + } } } } catch (throwable: Throwable) { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index c4c9cedca..e37aedbc6 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -33,11 +33,17 @@ object LorenzUtils { val inKuudraFight: Boolean get() = skyBlockIsland == "Instanced" - const val DEBUG_PREFIX = "[Debug] §7" + const val DEBUG_PREFIX = "[SkyHanni Debug] §7" private val log = LorenzLogger("chat/mod_sent") fun debug(message: String) { - internalChat(DEBUG_PREFIX + message) + if (SkyHanniMod.feature.dev.debugEnabled) { + if (internalChat(DEBUG_PREFIX + message)) { + consoleLog("[Debug] $message") + } + } else { + consoleLog("[Debug] $message") + } } fun warning(message: String) { @@ -52,21 +58,22 @@ object LorenzUtils { internalChat(message) } - private fun internalChat(message: String) { + private fun internalChat(message: String): Boolean { log.log(message) val minecraft = Minecraft.getMinecraft() if (minecraft == null) { consoleLog(message.removeColor()) - return + return false } val thePlayer = minecraft.thePlayer if (thePlayer == null) { consoleLog(message.removeColor()) - return + return false } thePlayer.addChatMessage(ChatComponentText(message)) + return true } //TODO move into StringUtils diff --git a/src/main/java/at/hannibal2/skyhanni/utils/MinecraftConsoleFilter.kt b/src/main/java/at/hannibal2/skyhanni/utils/MinecraftConsoleFilter.kt index c0e64c7be..9882f8578 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/MinecraftConsoleFilter.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/MinecraftConsoleFilter.kt @@ -130,15 +130,19 @@ class MinecraftConsoleFilter(private val loggerConfigName: String) : Filter { if (cause.stackTrace.isNotEmpty()) { val first = cause.stackTrace[0] if (SkyHanniMod.feature.dev.filterScoreboardErrors) { - if (first.toString() == "net.minecraft.scoreboard.Scoreboard.removeTeam(Scoreboard.java:229)") { + val firstName = first.toString() + if (firstName == "net.minecraft.scoreboard.Scoreboard.removeTeam(Scoreboard.java:229)" || + firstName == "net.minecraft.scoreboard.Scoreboard.removeTeam(Scoreboard.java:262)" + ) { filterConsole("NullPointerException at Scoreboard.removeTeam") return Filter.Result.DENY } - if (first.toString() == "net.minecraft.scoreboard.Scoreboard.createTeam(Scoreboard.java:218)") { + if (firstName == "net.minecraft.scoreboard.Scoreboard.createTeam(Scoreboard.java:218)") { filterConsole("IllegalArgumentException at Scoreboard.createTeam") return Filter.Result.DENY } - if (first.toString() == "net.minecraft.scoreboard.Scoreboard.removeObjective(Scoreboard.java:179)") { + if (firstName == "net.minecraft.scoreboard.Scoreboard.removeObjective(Scoreboard.java:179)" || + firstName == "net.minecraft.scoreboard.Scoreboard.removeObjective(Scoreboard.java:198)") { filterConsole("IllegalArgumentException at Scoreboard.removeObjective") return Filter.Result.DENY } -- cgit From 607a7cd9802b97f8102fdc535ed03090123f05ad Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 6 Jan 2023 23:26:46 +0100 Subject: Added /shtrackcollection. --- .../java/at/hannibal2/skyhanni/SkyHanniMod.java | 1 + .../at/hannibal2/skyhanni/config/Features.java | 5 + .../hannibal2/skyhanni/config/commands/Commands.kt | 2 + .../hannibal2/skyhanni/config/features/Misc.java | 5 + .../skyhanni/features/CollectionCounter.kt | 155 +++++++++++++++++++++ 5 files changed, 168 insertions(+) create mode 100644 src/main/java/at/hannibal2/skyhanni/features/CollectionCounter.kt diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index a88ef4696..ba48a5103 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -163,6 +163,7 @@ public class SkyHanniMod { registerEvent(new GriffinBurrowHelper()); registerEvent(new GriffinBurrowParticleFinder()); registerEvent(new BurrowWarpHelper()); + registerEvent(new CollectionCounter()); registerEvent(new HighlightBonzoMasks()); registerEvent(new DungeonLevelColor()); registerEvent(new BazaarCancelledBuyOrderClipboard()); diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.java b/src/main/java/at/hannibal2/skyhanni/config/Features.java index 0f7f0fd6c..976a0d9da 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Features.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Features.java @@ -37,6 +37,11 @@ public class Features extends Config { return; } + if (runnableId.equals("collectionCounter")) { + editOverlay(activeConfigCategory, 200, 16, misc.collectionCounterPos); + return; + } + if (runnableId.equals("debugPos")) { editOverlay(activeConfigCategory, 200, 16, dev.debugPos); return; diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index 5d94d850c..e51f9d92c 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.config.ConfigEditor import at.hannibal2.skyhanni.config.commands.SimpleCommand.ProcessCommandRunnable import at.hannibal2.skyhanni.config.core.GuiScreenElementWrapper +import at.hannibal2.skyhanni.features.CollectionCounter import at.hannibal2.skyhanni.features.MarkedPlayerManager import at.hannibal2.skyhanni.features.event.diana.BurrowWarpHelper import at.hannibal2.skyhanni.test.LorenzTest @@ -37,6 +38,7 @@ object Commands { registerCommand("togglepacketlog") { LorenzTest.togglePacketLog() } registerCommand("shreloadlisteners") { LorenzTest.reloadListeners() } registerCommand("shresetburrowwarps") { BurrowWarpHelper.resetDisabledWarps() } + registerCommand("shtrackcollection") { CollectionCounter.command(it) } } private fun registerCommand(name: String, function: (Array) -> Unit) { diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java index 5420aec36..a47b7979e 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java @@ -134,4 +134,9 @@ public class Misc { @ConfigOption(name = "Config Button", desc = "Add a button to the pause menu to configure SkyHanni.") @ConfigEditorBoolean public boolean configButtonOnPause = true; + + @Expose + @ConfigOption(name = "Collection Counter Position", desc = "Tracking the number of items you collect. §cDoes not work with sacks.") + @ConfigEditorButton(runnableId = "collectionCounter", buttonText = "Edit") + public Position collectionCounterPos = new Position(10, 10, false, true); } \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/CollectionCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/CollectionCounter.kt new file mode 100644 index 000000000..4124762b8 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/CollectionCounter.kt @@ -0,0 +1,155 @@ +package at.hannibal2.skyhanni.features + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.ProfileApiDataLoadedEvent +import at.hannibal2.skyhanni.features.bazaar.BazaarApi +import at.hannibal2.skyhanni.features.bazaar.BazaarData +import at.hannibal2.skyhanni.test.GriffinJavaUtils +import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.RenderUtils.renderString +import net.minecraft.client.Minecraft +import net.minecraftforge.client.event.RenderGameOverlayEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.gameevent.TickEvent + +class CollectionCounter { + + companion object { + + private var textToRender = "" + private var itemName = "" + private var itemApiName = "" + private var itemAmount = -1 + + private var lastAmountInInventory = -1 + + private val apiCollectionData = mutableMapOf() + + fun command(args: Array) { + if (args.isEmpty()) { + if (itemName == "") { + LorenzUtils.chat("§c/shtrackcollection ") + return + } + LorenzUtils.chat("§e[SkyHanni] Disabled collection tracking for $itemName") + apiCollectionData[itemApiName] = itemAmount + resetData() + return + } + + var name = args.joinToString(" ") + + var data: BazaarData? = null + for (bazaarData in BazaarApi.bazaarMap.values) { + if (bazaarData.itemName.equals(name, ignoreCase = true)) { + data = bazaarData + break + } + } + + if (data == null) { + LorenzUtils.error("Item '$name' not found!") + return + } + name = data.itemName + + val apiName = data.apiName + if (!apiCollectionData.contains(apiName)) { + LorenzUtils.error("Item '$name' not in collection data!") + return + } + + if (itemAmount != -1) { + resetData() + } + + itemName = name + itemApiName = apiName + itemAmount = apiCollectionData[apiName]!! + + lastAmountInInventory = countCurrentlyInInventory() + update() + LorenzUtils.chat("§e[SkyHanni] Enabled collection tracking for $itemName") + } + + private fun resetData() { + itemAmount = -1 + itemName = "" + itemApiName = "" + + lastAmountInInventory = -1 + textToRender = "" + } + + private fun update() { + val format = GriffinJavaUtils.formatInteger(itemAmount) + textToRender = "$itemName collection: $format" + } + + private fun countCurrentlyInInventory(): Int { + var currentlyInInventory = 0 + val player = Minecraft.getMinecraft().thePlayer + for (stack in player.inventory.mainInventory) { + if (stack == null) continue + val internalName = stack.getInternalName() + if (internalName == itemApiName) { + currentlyInInventory += stack.stackSize + } + } + return currentlyInInventory + } + } + + @SubscribeEvent + fun onTick(event: TickEvent.ClientTickEvent) { + val thePlayer = Minecraft.getMinecraft().thePlayer ?: return + thePlayer.worldObj ?: return + + if (lastAmountInInventory == -1) return + + if (Minecraft.getMinecraft().currentScreen != null) return + + val currentlyInInventory = countCurrentlyInInventory() + val diff = currentlyInInventory - lastAmountInInventory + if (diff != 0) { + if (diff > 0) { + itemAmount += diff + update() + } else { + LorenzUtils.debug("Collection counter! Negative collection change: $diff") + } + } + + lastAmountInInventory = currentlyInInventory + } + + @SubscribeEvent + fun onProfileDataLoad(event: ProfileApiDataLoadedEvent) { + val profileData = event.profileData + val collection = profileData["collection"].asJsonObject + + apiCollectionData.clear() + for (entry in collection.entrySet()) { + val name = entry.key + val value = entry.value.asInt + apiCollectionData[name] = value + if (name == itemApiName) { + val diff = value - itemAmount + if (diff != 0) { + LorenzUtils.debug("Collection counter was wrong by $diff items. (Compared against API data)") + } + itemAmount = value + update() + } + } + } + + @SubscribeEvent + fun onRenderOverlay(event: RenderGameOverlayEvent.Post) { + if (event.type != RenderGameOverlayEvent.ElementType.ALL) return + if (!LorenzUtils.inSkyblock) return + + SkyHanniMod.feature.misc.collectionCounterPos.renderString(textToRender) + } +} \ No newline at end of file -- cgit From 27017f5e523aadf7c2bb1c8e2f5b677bf47f2cc2 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 6 Jan 2023 23:27:00 +0100 Subject: Added /shtrackcollection. --- CHANGELOG.md | 3 +++ FEATURES.md | 1 + 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e3818601..3d69e944d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Version 0.13.1 +### Features ++ Added /shtrackcollection - This tracks the number of items you collect, but it does not work with sacks. + ### Fixes + Dungeon level color fixed wrong colors. diff --git a/FEATURES.md b/FEATURES.md index 552552f9c..7f44a497d 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -140,6 +140,7 @@ ## Commands - /wiki (using hypixel-skyblock.fandom.com instead of Hypixel wiki) - /shmarkplayer (marking a player with yellow color) +- /shtrackcollection - This tracks the number of items you collect, but it does not work with sacks. - ## Misc - Allow to copy, paste, and mark selected text in signs (not visual, but it's working still) -- cgit From bdd4102b67c7498c366370e265f67ad25698950b Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 6 Jan 2023 23:27:58 +0100 Subject: Reloading the profile data every 3 minutes. --- .../java/at/hannibal2/skyhanni/SkyHanniMod.java | 2 +- .../at/hannibal2/skyhanni/data/ApiDataLoader.kt | 146 +++++++++++++++++++++ .../at/hannibal2/skyhanni/data/ApiKeyGrabber.kt | 127 ------------------ 3 files changed, 147 insertions(+), 128 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt delete mode 100644 src/main/java/at/hannibal2/skyhanni/data/ApiKeyGrabber.kt diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index ba48a5103..0c68a9f89 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -89,7 +89,7 @@ public class SkyHanniMod { registerEvent(new HypixelData()); registerEvent(new DungeonData()); registerEvent(new ScoreboardData()); - registerEvent(new ApiKeyGrabber()); + registerEvent(new ApiDataLoader()); registerEvent(new SeaCreatureManager()); registerEvent(new ItemRenderBackground()); registerEvent(new EntityData()); diff --git a/src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt b/src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt new file mode 100644 index 000000000..bea039212 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/data/ApiDataLoader.kt @@ -0,0 +1,146 @@ +package at.hannibal2.skyhanni.data + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.ProfileApiDataLoadedEvent +import at.hannibal2.skyhanni.events.ProfileJoinEvent +import at.hannibal2.skyhanni.utils.APIUtil +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.StringUtils.toDashlessUUID +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext +import net.minecraft.client.Minecraft +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.gameevent.TickEvent +import java.io.File +import java.util.* + +class ApiDataLoader { + + private var currentProfileName = "" + + private var nextApiCallTime = -1L + private var currentProfileId = "" + + @SubscribeEvent + fun onTick(event: TickEvent.ClientTickEvent) { + val thePlayer = Minecraft.getMinecraft().thePlayer ?: return + thePlayer.worldObj ?: return + + if (nextApiCallTime != -1L && System.currentTimeMillis() > nextApiCallTime) { + nextApiCallTime = System.currentTimeMillis() + 60_000 * 5 + SkyHanniMod.coroutineScope.launch { + val apiKey = SkyHanniMod.feature.hidden.apiKey + val uuid = Minecraft.getMinecraft().thePlayer.uniqueID.toDashlessUUID() + loadProfileData(apiKey, uuid, currentProfileId) + } + } + } + + @SubscribeEvent + fun onStatusBar(event: LorenzChatEvent) { + val message = event.message + if (message.startsWith("§aYour new API key is §r§b")) { + SkyHanniMod.feature.hidden.apiKey = message.substring(26) + LorenzUtils.chat("§b[SkyHanni] A new API Key has been detected and installed") + + if (currentProfileName != "") { + updateApiData() + } + } + } + + @SubscribeEvent + fun onStatusBar(event: ProfileJoinEvent) { + currentProfileName = event.name + updateApiData() + } + + private suspend fun tryUpdateProfileDataAndVerifyKey(apiKey: String): Boolean { + val uuid = Minecraft.getMinecraft().thePlayer.uniqueID.toDashlessUUID() + val url = "https://api.hypixel.net/player?key=$apiKey&uuid=$uuid" + val jsonObject = withContext(Dispatchers.IO) { APIUtil.getJSONResponse(url) } + + if (jsonObject["success"]?.asBoolean == false) { + if (jsonObject["throttle"]?.asBoolean == true) return true // 429 Too Many Requests does not make an invalid key. + val cause = jsonObject["cause"].asString + if (cause == "Invalid API key") { + return false + } else { + throw RuntimeException("API error for url '$url': $cause") + } + } + val player = jsonObject["player"].asJsonObject + val stats = player["stats"].asJsonObject + val skyBlock = stats["SkyBlock"].asJsonObject + val profiles = skyBlock["profiles"].asJsonObject + for (entry in profiles.entrySet()) { + val asJsonObject = entry.value.asJsonObject + val name = asJsonObject["cute_name"].asString + if (currentProfileName == name.lowercase()) { + currentProfileId = asJsonObject["profile_id"].asString + loadProfileData(apiKey, uuid, currentProfileId) + } + } + return true + } + + private fun updateApiData() { + nextApiCallTime = -1 + SkyHanniMod.coroutineScope.launch { + val oldApiKey = SkyHanniMod.feature.hidden.apiKey + if (oldApiKey.isNotEmpty() && tryUpdateProfileDataAndVerifyKey(oldApiKey)) { + return@launch + } + findApiCandidatesFromOtherMods().forEach { (modName, newApiKey) -> + if (tryUpdateProfileDataAndVerifyKey(newApiKey)) { + SkyHanniMod.feature.hidden.apiKey = newApiKey + LorenzUtils.chat("§e[SkyHanni] Imported valid new API key from $modName.") + return@launch + } else { + LorenzUtils.error("§c[SkyHanni] Invalid API key from $modName") + } + } + LorenzUtils.error("§c[SkyHanni] SkyHanni has no API key set. Please run /api new") + } + } + + private fun findApiCandidatesFromOtherMods(): Map { + LorenzUtils.consoleLog("Trying to find the API Key from the config of other mods..") + val candidates = mutableMapOf() + for (mod in OtherMod.values()) { + val modName = mod.modName + val file = File(mod.configPath) + if (file.exists()) { + val reader = APIUtil.readFile(file) + try { + val key = mod.readKey(reader).replace("\n", "").replace(" ", "") + UUID.fromString(key) + candidates[modName] = key + } catch (e: Throwable) { + LorenzUtils.consoleLog("- $modName: wrong config format! (" + e.message + ")") + continue + } + } else { + LorenzUtils.consoleLog("- $modName: no config found!") + } + } + return candidates + } + + private suspend fun loadProfileData(apiKey: String, playerUuid: String, profileId: String) { + val url = "https://api.hypixel.net/skyblock/profile?key=$apiKey&profile=$profileId" + + val jsonObject = withContext(Dispatchers.IO) { APIUtil.getJSONResponse(url) } + val profile = jsonObject["profile"]?.asJsonObject ?: return + val members = profile["members"]?.asJsonObject ?: return + for (entry in members.entrySet()) { + if (entry.key == playerUuid) { + val profileData = entry.value.asJsonObject + ProfileApiDataLoadedEvent(profileData).postAndCatch() + nextApiCallTime = System.currentTimeMillis() + 60_000 * 3 + } + } + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/ApiKeyGrabber.kt b/src/main/java/at/hannibal2/skyhanni/data/ApiKeyGrabber.kt deleted file mode 100644 index 000d21805..000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/ApiKeyGrabber.kt +++ /dev/null @@ -1,127 +0,0 @@ -package at.hannibal2.skyhanni.data - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.ProfileApiDataLoadedEvent -import at.hannibal2.skyhanni.events.ProfileJoinEvent -import at.hannibal2.skyhanni.utils.APIUtil -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.StringUtils.toDashlessUUID -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.launch -import kotlinx.coroutines.withContext -import net.minecraft.client.Minecraft -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -import java.io.File -import java.util.* - -class ApiKeyGrabber { - - private var currentProfileName = "" - - @SubscribeEvent - fun onStatusBar(event: LorenzChatEvent) { - val message = event.message - if (message.startsWith("§aYour new API key is §r§b")) { - SkyHanniMod.feature.hidden.apiKey = message.substring(26) - LorenzUtils.chat("§b[SkyHanni] A new API Key has been detected and installed") - - if (currentProfileName != "") { - updateApiData() - } - } - } - - @SubscribeEvent - fun onStatusBar(event: ProfileJoinEvent) { - currentProfileName = event.name - updateApiData() - } - - - private suspend fun tryUpdateProfileDataAndVerifyKey(apiKey: String): Boolean { - val uuid = Minecraft.getMinecraft().thePlayer.uniqueID.toDashlessUUID() - val url = "https://api.hypixel.net/player?key=$apiKey&uuid=$uuid" - val jsonObject = withContext(Dispatchers.IO) { APIUtil.getJSONResponse(url) } - - if (jsonObject["success"]?.asBoolean == false) { - if (jsonObject["throttle"]?.asBoolean == true) return true // 429 Too Many Requests does not make an invalid key. - val cause = jsonObject["cause"].asString - if (cause == "Invalid API key") { - return false - } else { - throw RuntimeException("API error for url '$url': $cause") - } - } - val player = jsonObject["player"].asJsonObject - val stats = player["stats"].asJsonObject - val skyblock = stats["SkyBlock"].asJsonObject - val profiles = skyblock["profiles"].asJsonObject - for (entry in profiles.entrySet()) { - val asJsonObject = entry.value.asJsonObject - val name = asJsonObject["cute_name"].asString - if (currentProfileName == name.lowercase()) { - val profileId = asJsonObject["profile_id"].asString - loadProfile(apiKey, uuid, profileId) - } - } - return true - } - - private fun updateApiData() { - SkyHanniMod.coroutineScope.launch { - val oldApiKey = SkyHanniMod.feature.hidden.apiKey - if (oldApiKey.isNotEmpty() && tryUpdateProfileDataAndVerifyKey(oldApiKey)) { - return@launch - } - findApiCandidatesFromOtherMods().forEach { (modName, newApiKey) -> - if (tryUpdateProfileDataAndVerifyKey(newApiKey)) { - SkyHanniMod.feature.hidden.apiKey = newApiKey - LorenzUtils.chat("§e[SkyHanni] Imported valid new API key from $modName.") - return@launch - } else { - LorenzUtils.error("§c[SkyHanni] Invalid API key from $modName") - } - } - LorenzUtils.error("§c[SkyHanni] SkyHanni has no API key set. Please run /api new") - } - } - - private fun findApiCandidatesFromOtherMods(): Map { - LorenzUtils.consoleLog("Trying to find the API Key from the config of other mods..") - val candidates = mutableMapOf() - for (mod in OtherMod.values()) { - val modName = mod.modName - val file = File(mod.configPath) - if (file.exists()) { - val reader = APIUtil.readFile(file) - try { - val key = mod.readKey(reader).replace("\n", "").replace(" ", "") - UUID.fromString(key) - candidates[modName] = key - } catch (e: Throwable) { - LorenzUtils.consoleLog("- $modName: wrong config format! (" + e.message + ")") - continue - } - } else { - LorenzUtils.consoleLog("- $modName: no config found!") - } - } - return candidates - } - - private suspend fun loadProfile(apiKey: String, playerUuid: String, profileId: String) { - val url = "https://api.hypixel.net/skyblock/profile?key=$apiKey&profile=$profileId" - - val jsonObject = withContext(Dispatchers.IO) { APIUtil.getJSONResponse(url) } - - val profile = jsonObject["profile"]?.asJsonObject ?: return - val members = profile["members"]?.asJsonObject ?: return - for (entry in members.entrySet()) { - if (entry.key == playerUuid) { - val profileData = entry.value.asJsonObject - ProfileApiDataLoadedEvent(profileData).postAndCatch() - } - } - } -} \ No newline at end of file -- cgit From c7fd8e858893128913659934e7524f61ab78745c Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 6 Jan 2023 23:28:47 +0100 Subject: Renaming onRenderOverlay. --- src/main/java/at/hannibal2/skyhanni/data/SendTitleHelper.kt | 2 +- src/main/java/at/hannibal2/skyhanni/features/CurrentPetDisplay.kt | 2 +- src/main/java/at/hannibal2/skyhanni/features/NonGodPotEffectDisplay.kt | 2 +- src/main/java/at/hannibal2/skyhanni/features/RealTime.kt | 2 +- src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCopilot.kt | 2 +- .../java/at/hannibal2/skyhanni/features/dungeon/DungeonDeathCounter.kt | 2 +- .../at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt | 2 +- .../hannibal2/skyhanni/features/nether/ashfang/AshfangFreezeCooldown.kt | 2 +- .../skyhanni/features/nether/ashfang/AshfangNextResetCooldown.kt | 2 +- .../hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt | 2 +- .../at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerPillar.kt | 2 +- .../at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt | 2 +- src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/SendTitleHelper.kt b/src/main/java/at/hannibal2/skyhanni/data/SendTitleHelper.kt index eda151f97..f3807be83 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SendTitleHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SendTitleHelper.kt @@ -20,7 +20,7 @@ class SendTitleHelper { } @SubscribeEvent - fun renderOverlay(event: RenderGameOverlayEvent.Post) { + fun onRenderOverlay(event: RenderGameOverlayEvent.Post) { if (event.type != RenderGameOverlayEvent.ElementType.ALL) return if (System.currentTimeMillis() > endTime) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/CurrentPetDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/CurrentPetDisplay.kt index 0048114a3..29d5d037c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/CurrentPetDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/CurrentPetDisplay.kt @@ -37,7 +37,7 @@ class CurrentPetDisplay { } @SubscribeEvent - fun renderOverlay(event: RenderGameOverlayEvent.Post) { + fun onRenderOverlay(event: RenderGameOverlayEvent.Post) { if (event.type != RenderGameOverlayEvent.ElementType.ALL) return if (!LorenzUtils.inSkyblock) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/NonGodPotEffectDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/NonGodPotEffectDisplay.kt index 7f449b0ba..5ac2a00dd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/NonGodPotEffectDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/NonGodPotEffectDisplay.kt @@ -178,7 +178,7 @@ class NonGodPotEffectDisplay { } @SubscribeEvent - fun renderOverlay(event: RenderGameOverlayEvent.Post) { + fun onRenderOverlay(event: RenderGameOverlayEvent.Post) { if (event.type != RenderGameOverlayEvent.ElementType.ALL) return if (!isEnabled()) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/RealTime.kt b/src/main/java/at/hannibal2/skyhanni/features/RealTime.kt index de1d1b06e..a3c9e9685 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/RealTime.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/RealTime.kt @@ -12,7 +12,7 @@ class RealTime { private val format = SimpleDateFormat("HH:mm:ss") @SubscribeEvent - fun renderOverlay(event: RenderGameOverlayEvent.Post) { + fun onRenderOverlay(event: RenderGameOverlayEvent.Post) { if (event.type != RenderGameOverlayEvent.ElementType.ALL) return if (!isEnabled()) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCopilot.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCopilot.kt index ef19d53ec..15d1475f6 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCopilot.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonCopilot.kt @@ -126,7 +126,7 @@ class DungeonCopilot { } @SubscribeEvent - fun renderOverlay(event: RenderGameOverlayEvent.Post) { + fun onRenderOverlay(event: RenderGameOverlayEvent.Post) { if (event.type != RenderGameOverlayEvent.ElementType.ALL) return if (!isEnabled()) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonDeathCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonDeathCounter.kt index a65ee67c1..672e2d262 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonDeathCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonDeathCounter.kt @@ -85,7 +85,7 @@ class DungeonDeathCounter { } @SubscribeEvent - fun renderOverlay(event: RenderGameOverlayEvent.Post) { + fun onRenderOverlay(event: RenderGameOverlayEvent.Post) { if (event.type != RenderGameOverlayEvent.ElementType.ALL) return if (!isEnabled()) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt index 97798b04b..9457d4a5d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonMilestonesDisplay.kt @@ -84,7 +84,7 @@ class DungeonMilestonesDisplay { } @SubscribeEvent - fun renderOverlay(event: RenderGameOverlayEvent.Post) { + fun onRenderOverlay(event: RenderGameOverlayEvent.Post) { if (event.type != RenderGameOverlayEvent.ElementType.ALL) return if (!isEnabled()) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangFreezeCooldown.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangFreezeCooldown.kt index 3c6c6af88..92692cc65 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangFreezeCooldown.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangFreezeCooldown.kt @@ -26,7 +26,7 @@ class AshfangFreezeCooldown { } @SubscribeEvent - fun renderOverlay(event: RenderGameOverlayEvent.Post) { + fun onRenderOverlay(event: RenderGameOverlayEvent.Post) { if (event.type != RenderGameOverlayEvent.ElementType.ALL) return if (!isEnabled()) return val duration = System.currentTimeMillis() - lastHit diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangNextResetCooldown.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangNextResetCooldown.kt index ec171e2d8..8590c2b36 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangNextResetCooldown.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/ashfang/AshfangNextResetCooldown.kt @@ -30,7 +30,7 @@ class AshfangNextResetCooldown { } @SubscribeEvent - fun renderOverlay(event: RenderGameOverlayEvent.Post) { + fun onRenderOverlay(event: RenderGameOverlayEvent.Post) { if (event.type != RenderGameOverlayEvent.ElementType.ALL) return if (!isEnabled()) return if (spawnTime == -1L) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt index 793764000..4ae548836 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt @@ -245,7 +245,7 @@ class BlazeSlayerDaggerHelper { } @SubscribeEvent - fun renderOverlay(event: RenderGameOverlayEvent.Post) { + fun onRenderOverlay(event: RenderGameOverlayEvent.Post) { if (event.type != RenderGameOverlayEvent.ElementType.ALL) return if (!isEnabled()) return if (textTopLeft.isEmpty()) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerPillar.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerPillar.kt index 214e25eb7..22f22e904 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerPillar.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerPillar.kt @@ -96,7 +96,7 @@ class BlazeSlayerPillar { } @SubscribeEvent - fun renderOverlay(event: RenderGameOverlayEvent.Post) { + fun onRenderOverlay(event: RenderGameOverlayEvent.Post) { if (event.type != RenderGameOverlayEvent.ElementType.ALL) return if (!isEnabled()) return if (lastPillarSpawnTime == -1L) return diff --git a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt index 41357fbb8..a4047a7c2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt @@ -137,7 +137,7 @@ class SummoningMobManager { } @SubscribeEvent - fun renderOverlay(event: RenderGameOverlayEvent.Post) { + fun onRenderOverlay(event: RenderGameOverlayEvent.Post) { if (event.type != RenderGameOverlayEvent.ElementType.ALL) return if (!LorenzUtils.inSkyblock) return if (!SkyHanniMod.feature.summonings.summoningMobDisplay) return diff --git a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt b/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt index 8f0c4cc2c..3f1cfa4da 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/LorenzTest.kt @@ -120,7 +120,7 @@ class LorenzTest { } @SubscribeEvent - fun renderOverlay(event: RenderGameOverlayEvent.Post) { + fun onRenderOverlay(event: RenderGameOverlayEvent.Post) { if (event.type != RenderGameOverlayEvent.ElementType.ALL) return if (!LorenzUtils.inSkyblock) return if (!SkyHanniMod.feature.dev.debugEnabled) return -- cgit From 95e52d80f87d1cf9fe26711c9c8d2fe01a5c10aa Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Fri, 6 Jan 2023 23:53:51 +0100 Subject: Fixed 1/1000000 crash. --- src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt index 97bba3099..3f8f1ce68 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt @@ -424,7 +424,8 @@ object RenderUtils { return lastValue + (currentValue - lastValue) * multiplier } - fun Position.renderString(string: String, offsetY: Int = 0) { + fun Position.renderString(string: String?, offsetY: Int = 0) { + if (string == null) return if (string == "") return val textToRender = "§f$string" -- cgit From 95c048b61131a16ab0109fdf7c62027b95bee369 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 7 Jan 2023 00:39:06 +0100 Subject: Show collection gain. --- .../skyhanni/features/CollectionCounter.kt | 67 +++++++++++++++++----- 1 file changed, 53 insertions(+), 14 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/CollectionCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/CollectionCounter.kt index 4124762b8..98488815f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/CollectionCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/CollectionCounter.kt @@ -15,15 +15,21 @@ import net.minecraftforge.fml.common.gameevent.TickEvent class CollectionCounter { + private val RECENT_GAIN_TIME = 1_500 + companion object { - private var textToRender = "" + private var display = "" + private var itemName = "" private var itemApiName = "" private var itemAmount = -1 private var lastAmountInInventory = -1 + private var recentGain = 0 + private var lastGainTime = -1L + private val apiCollectionData = mutableMapOf() fun command(args: Array) { @@ -32,7 +38,7 @@ class CollectionCounter { LorenzUtils.chat("§c/shtrackcollection ") return } - LorenzUtils.chat("§e[SkyHanni] Disabled collection tracking for $itemName") + LorenzUtils.chat("§e[SkyHanni] Stopped collection tracker.") apiCollectionData[itemApiName] = itemAmount resetData() return @@ -49,14 +55,14 @@ class CollectionCounter { } if (data == null) { - LorenzUtils.error("Item '$name' not found!") + LorenzUtils.chat("§c[SkyHanni] Item '$name' not found!") return } name = data.itemName val apiName = data.apiName if (!apiCollectionData.contains(apiName)) { - LorenzUtils.error("Item '$name' not in collection data!") + LorenzUtils.chat("§c[SkyHanni] Item $name not in collection data!") return } @@ -69,8 +75,8 @@ class CollectionCounter { itemAmount = apiCollectionData[apiName]!! lastAmountInInventory = countCurrentlyInInventory() - update() - LorenzUtils.chat("§e[SkyHanni] Enabled collection tracking for $itemName") + updateDisplay() + LorenzUtils.chat("§e[SkyHanni] Started tracking $itemName collection.") } private fun resetData() { @@ -79,12 +85,20 @@ class CollectionCounter { itemApiName = "" lastAmountInInventory = -1 - textToRender = "" + display = "" + + recentGain = 0 } - private fun update() { + private fun updateDisplay() { val format = GriffinJavaUtils.formatInteger(itemAmount) - textToRender = "$itemName collection: $format" + + var gainText = "" + if (recentGain != 0) { + gainText = "§a+" + GriffinJavaUtils.formatInteger(recentGain) + } + + display = "$itemName collection: §e$format $gainText" } private fun countCurrentlyInInventory(): Int { @@ -106,16 +120,19 @@ class CollectionCounter { val thePlayer = Minecraft.getMinecraft().thePlayer ?: return thePlayer.worldObj ?: return - if (lastAmountInInventory == -1) return + compareInventory() + updateGain() + } + private fun compareInventory() { + if (lastAmountInInventory == -1) return if (Minecraft.getMinecraft().currentScreen != null) return val currentlyInInventory = countCurrentlyInInventory() val diff = currentlyInInventory - lastAmountInInventory if (diff != 0) { if (diff > 0) { - itemAmount += diff - update() + gainItems(diff) } else { LorenzUtils.debug("Collection counter! Negative collection change: $diff") } @@ -124,6 +141,27 @@ class CollectionCounter { lastAmountInInventory = currentlyInInventory } + private fun updateGain() { + if (recentGain != 0) { + if (System.currentTimeMillis() > lastGainTime + RECENT_GAIN_TIME) { + recentGain = 0 + updateDisplay() + } + } + } + + private fun gainItems(amount: Int) { + itemAmount += amount + + if (System.currentTimeMillis() > lastGainTime + RECENT_GAIN_TIME) { + recentGain = 0 + } + lastGainTime = System.currentTimeMillis() + recentGain += amount + + updateDisplay() + } + @SubscribeEvent fun onProfileDataLoad(event: ProfileApiDataLoadedEvent) { val profileData = event.profileData @@ -140,7 +178,8 @@ class CollectionCounter { LorenzUtils.debug("Collection counter was wrong by $diff items. (Compared against API data)") } itemAmount = value - update() + recentGain = 0 + updateDisplay() } } } @@ -150,6 +189,6 @@ class CollectionCounter { if (event.type != RenderGameOverlayEvent.ElementType.ALL) return if (!LorenzUtils.inSkyblock) return - SkyHanniMod.feature.misc.collectionCounterPos.renderString(textToRender) + SkyHanniMod.feature.misc.collectionCounterPos.renderString(display) } } \ No newline at end of file -- cgit From a824460d13ef99f6fa51597de704893d1e55acc6 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 7 Jan 2023 01:22:50 +0100 Subject: Don't render overlays when tab list key is pressed. --- CHANGELOG.md | 3 +++ src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d69e944d..6de968e79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ ### Features + Added /shtrackcollection - This tracks the number of items you collect, but it does not work with sacks. +### Changes ++ Don't render overlays when tab list key is pressed. + ### Fixes + Dungeon level color fixed wrong colors. diff --git a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt index 3f8f1ce68..3697838c7 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/RenderUtils.kt @@ -425,14 +425,17 @@ object RenderUtils { } fun Position.renderString(string: String?, offsetY: Int = 0) { + val minecraft = Minecraft.getMinecraft() + if (minecraft.gameSettings.keyBindPlayerList.isKeyDown) return + if (string == null) return if (string == "") return val textToRender = "§f$string" GlStateManager.pushMatrix() - val resolution = ScaledResolution(Minecraft.getMinecraft()) + val resolution = ScaledResolution(minecraft) - val renderer = Minecraft.getMinecraft().renderManager.fontRenderer ?: return + val renderer = minecraft.renderManager.fontRenderer ?: return val offsetX = (200 - renderer.getStringWidth(textToRender.removeColor())) / 2 -- cgit From 6ab6795eb479dfcae3e03b68ace173cf9db457fe Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 7 Jan 2023 01:34:47 +0100 Subject: changed color for CroesusUnopenedChestTracker --- .../hannibal2/skyhanni/features/dungeon/CroesusUnopenedChestTracker.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/CroesusUnopenedChestTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/CroesusUnopenedChestTracker.kt index ae5d5511d..8cda8aade 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/CroesusUnopenedChestTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/CroesusUnopenedChestTracker.kt @@ -30,7 +30,7 @@ class CroesusUnopenedChestTracker { val lore = stack.getLore() if (lore.any { it.contains("Click to view") }) { if (!lore.any { it.contains("Chests have been opened!") }) { - slot highlight LorenzColor.GREEN + slot highlight LorenzColor.DARK_PURPLE } } } -- cgit From c4ab4cf0200381effc50309c5b4f2ba689b3c438 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 7 Jan 2023 01:58:03 +0100 Subject: Add support for ironman, stranded and bingo. --- .../java/at/hannibal2/skyhanni/data/HypixelData.kt | 55 +++++++++++++++++----- .../at/hannibal2/skyhanni/utils/LorenzUtils.kt | 6 +++ 2 files changed, 48 insertions(+), 13 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt index 53a1286d3..8026ecac8 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt @@ -19,6 +19,13 @@ class HypixelData { var skyblock = false var skyBlockIsland: String = "" + //Ironman, Stranded and Bingo + var noTrade = false + + var ironman = false + var stranded = false + var bingo = false + fun readSkyBlockArea(): String { for (line in ScoreboardData.sidebarLinesFormatted()) { if (line.startsWith(" §7⏣ ")) { @@ -28,7 +35,6 @@ class HypixelData { return "invalid" } - } var loggerIslandChange = LorenzLogger("debug/island_change") @@ -57,7 +63,6 @@ class HypixelData { if (!hypixel) return val message = event.message.removeColor().lowercase() - if (message.startsWith("your profile was changed to:")) { val stripped = message.replace("your profile was changed to:", "").replace("(co-op)", "").trim() ProfileJoinEvent(stripped).postAndCatch() @@ -65,7 +70,6 @@ class HypixelData { if (message.startsWith("you are playing on profile:")) { val stripped = message.replace("you are playing on profile:", "").replace("(co-op)", "").trim() ProfileJoinEvent(stripped).postAndCatch() - } } @@ -80,13 +84,42 @@ class HypixelData { if (tick % 5 != 0) return - val newState = checkScoreboard() - if (newState) { + val inSkyBlock = checkScoreboard() + if (inSkyBlock) { checkIsland() + checkSidebar() } - if (newState == skyblock) return - skyblock = newState + if (inSkyBlock == skyblock) return + skyblock = inSkyBlock + } + + private fun checkSidebar() { + ironman = false + stranded = false + bingo = false + + for (line in ScoreboardData.sidebarLinesFormatted()) { + when (line) { + " §7Ⓑ §7Bingo", // No Rank + " §bⒷ §bBingo", // Rank 1 + " §9Ⓑ §9Bingo", // Rank 2 + " §5Ⓑ §5Bingo", // Rank 3 + " §6Ⓑ §6Bingo", // Rank 4 + -> { + bingo = true + } + + // TODO implemennt stranded check + + " §7♲ §7Ironman" -> { + ironman = true + } + + } + } + + noTrade = ironman || stranded || bingo } private fun checkIsland() { @@ -115,12 +148,8 @@ class HypixelData { val minecraft = Minecraft.getMinecraft() val world = minecraft.theWorld ?: return false - val sidebarObjective = world.scoreboard.getObjectiveInDisplaySlot(1) ?: return false - - val displayName = sidebarObjective.displayName - + val objective = world.scoreboard.getObjectiveInDisplaySlot(1) ?: return false + val displayName = objective.displayName return displayName.removeColor().contains("SKYBLOCK") - } - } \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index e37aedbc6..f6e2e319c 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -33,6 +33,12 @@ object LorenzUtils { val inKuudraFight: Boolean get() = skyBlockIsland == "Instanced" + val noTradeMode: Boolean + get() = HypixelData.noTrade + + val isBingoProfile: Boolean + get() = inSkyblock && HypixelData.bingo + const val DEBUG_PREFIX = "[SkyHanni Debug] §7" private val log = LorenzLogger("chat/mod_sent") -- cgit From ac0c2ee4e8e17492feceb0007ccab4a6ddfc27da Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 7 Jan 2023 01:58:22 +0100 Subject: Removed unused code. --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 0c68a9f89..5a1e9fb7c 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -186,10 +186,7 @@ public class SkyHanniMod { private void registerEvent(Object object) { listenerClasses.add(object); - String simpleName = object.getClass().getSimpleName(); - long start = System.currentTimeMillis(); MinecraftForge.EVENT_BUS.register(object); - long duration = System.currentTimeMillis() - start; } public static GuiScreen screenToOpen = null; -- cgit From 81e2e14e71eb49b531562273ca9d306f3d76b530 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 7 Jan 2023 01:59:53 +0100 Subject: No longer blocking the sell of bazaar items to NPC when on ironman, stranded or bingo mode. --- CHANGELOG.md | 1 + .../hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6de968e79..4eac20119 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ ### Changes + Don't render overlays when tab list key is pressed. ++ No longer blocking the sell of bazaar items to NPC when on ironman, stranded or bingo mode. ### Fixes + Dungeon level color fixed wrong colors. diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt index 78735b5f9..0202566a0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/HideNotClickableItems.kt @@ -306,6 +306,12 @@ class HideNotClickableItems { } if (!ItemUtils.isRecombobulated(stack)) { + if (LorenzUtils.noTradeMode) { + if (BazaarApi.isBazaarItem(stack)) { + return false + } + } + if (hideNpcSellFilter.match(name)) return false val id = stack.getInternalName() -- cgit From cf9c5919746107cd4fc954f75b9d99223e1df591 Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sat, 7 Jan 2023 02:23:14 +0100 Subject: Compact Bingo and Potion Effect chat messages. --- CHANGELOG.md | 4 +- FEATURES.md | 4 + .../java/at/hannibal2/skyhanni/SkyHanniMod.java | 2 + .../at/hannibal2/skyhanni/config/Features.java | 4 + .../hannibal2/skyhanni/config/features/Bingo.java | 14 +++ .../hannibal2/skyhanni/config/features/Chat.java | 7 +- .../skyhanni/features/CompactBingoChat.kt | 112 +++++++++++++++++++++ .../features/CompactSplashPotionMessage.kt | 35 +++++++ 8 files changed, 180 insertions(+), 2 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/Bingo.java create mode 100644 src/main/java/at/hannibal2/skyhanni/features/CompactBingoChat.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/CompactSplashPotionMessage.kt diff --git a/CHANGELOG.md b/CHANGELOG.md index 4eac20119..72210d27a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,12 @@ ### Features + Added /shtrackcollection - This tracks the number of items you collect, but it does not work with sacks. ++ Added Compact Bingo Chat Messages ++ Added Compact Potion Effect Chat Messages ### Changes + Don't render overlays when tab list key is pressed. -+ No longer blocking the sell of bazaar items to NPC when on ironman, stranded or bingo mode. ++ Do no longer prevent the selling of bazaar items to NPC when on ironman, stranded or bingo mode. ### Fixes + Dungeon level color fixed wrong colors. diff --git a/FEATURES.md b/FEATURES.md index 7f44a497d..9687098b0 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -19,6 +19,7 @@ - Option to hide the death messages of other players, except for players who are close to the player, inside the dungeon or during a Kuudra fight. - Scan messages sent by players in all-chat for blacklisted words and greys out the message. - Chat peeking (holding key to display chat without opening the chat gui) +- Compact Potion Effect Messages ## Dungeon - Clicked Blocks (Showing the block behind walls AFTER clicked on a chest, wither essence or a lever) @@ -137,6 +138,9 @@ + Highlight marked player names in chat. + Mark the own player name. +## Bingo ++ Shortens chat messages about skill level ups, collection gains, new area discoveries, and bestiarity upgrades while on bingo. + ## Commands - /wiki (using hypixel-skyblock.fandom.com instead of Hypixel wiki) - /shmarkplayer (marking a player with yellow color) diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 5a1e9fb7c..d7670e810 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -167,7 +167,9 @@ public class SkyHanniMod { registerEvent(new HighlightBonzoMasks()); registerEv