diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostCounter.kt | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostCounter.kt index 82f80a044..2cbab2a26 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/ghostcounter/GhostCounter.kt @@ -53,12 +53,17 @@ object GhostCounter { val config get() = SkyHanniMod.feature.ghostCounter val hidden get() = ProfileStorageData.profileSpecific?.ghostCounter private var display = emptyList<List<Any>>() - var ghostCounterV3File = File("." + File.separator + "config" + File.separator + "ChatTriggers" + File.separator + "modules" + File.separator + "GhostCounterV3" + File.separator + ".persistantData.json") + var ghostCounterV3File = + File("." + File.separator + "config" + File.separator + "ChatTriggers" + File.separator + "modules" + File.separator + "GhostCounterV3" + File.separator + ".persistantData.json") private val skillXPPattern = "[+](?<gained>[0-9,.]+) \\((?<current>[0-9,.]+)(?:/(?<total>[0-9,.]+))?\\)".toPattern() - private val combatSectionPattern = ".*[+](?<gained>[0-9,.]+) (?<skillName>[A-Za-z]+) \\((?<progress>(?<current>[0-9.,]+)/(?<total>[0-9.,]+)|(?<percent>[0-9.]+)%)\\).*".toPattern() - private val killComboExpiredPattern = "§cYour Kill Combo has expired! You reached a (?<combo>.*) Kill Combo!".toPattern() - private val ghostXPPattern = "(?<current>\\d+(?:\\.\\d+)?(?:,\\d+)?[kK]?)\\/(?<total>\\d+(?:\\.\\d+)?(?:,\\d+)?[kKmM]?)".toPattern() - private val bestiaryPattern = ".*(?:§\\d|§\\w)+BESTIARY (?:§\\d|§\\w)+Ghost (?:§\\d|§\\w)(?<previousLevel>\\d+)➜(?:§\\d|§\\w)(?<nextLevel>\\d+).*".toPattern() // &3&lBESTIARY &b&lGhost &89➜&b10 + private val combatSectionPattern = + ".*[+](?<gained>[0-9,.]+) (?<skillName>[A-Za-z]+) \\((?<progress>(?<current>[0-9.,]+)/(?<total>[0-9.,]+)|(?<percent>[0-9.]+)%)\\).*".toPattern() + private val killComboExpiredPattern = + "§cYour Kill Combo has expired! You reached a (?<combo>.*) Kill Combo!".toPattern() + private val ghostXPPattern = + "(?<current>\\d+(?:\\.\\d+)?(?:,\\d+)?[kK]?)/(?<total>\\d+(?:\\.\\d+)?(?:,\\d+)?[kKmM]?)".toPattern() + private val bestiaryPattern = + ".*(?:§\\d|§\\w)+BESTIARY (?:§\\d|§\\w)+Ghost (?:§\\d|§\\w)(?<previousLevel>\\d+)➜(?:§\\d|§\\w)(?<nextLevel>\\d+).*".toPattern() // &3&lBESTIARY &b&lGhost &89➜&b10 private val skillLevelPattern = ".*§e§lSkills: §r§a(?<skillName>.*) (?<skillLevel>\\d+).*".toPattern() private val format = NumberFormat.getInstance() private var percent: Float = 0.0f @@ -76,15 +81,17 @@ object GhostCounter { private var killETA = "" private var currentSkill = "" private var currentSkillLevel = -1 - private const val configUpdateVersion = 1 + private const val CONFIG_VALUE_VERSION = 1 @SubscribeEvent fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) { if (!isEnabled()) return if (config.onlyOnMist && !inMist) return - config.position.renderStringsAndItems(display, + config.position.renderStringsAndItems( + display, extraSpace = config.extraSpace, - posLabel = "Ghost Counter") + posLabel = "Ghost Counter" + ) } private fun formatDisplay(map: List<List<Any>>): List<List<Any>> { @@ -206,7 +213,10 @@ object GhostCounter { addAsSingletonList(textFormatting.killComboFormat.formatText(MAXKILLCOMBO)) addAsSingletonList(textFormatting.highestKillComboFormat.formatText(MAXKILLCOMBO)) addAsSingletonList(textFormatting.skillXPGainFormat.formatText(SKILLXPGAINED)) - addAsSingletonList(bestiaryFormatting.base.preFormat(bestiary, nextLevel - 1, nextLevel).formatBestiary(currentKill, killNeeded)) + addAsSingletonList( + bestiaryFormatting.base.preFormat(bestiary, nextLevel - 1, nextLevel) + .formatBestiary(currentKill, killNeeded) + ) addAsSingletonList(xpHourFormatting.base.formatText(xp)) addAsSingletonList(killHourFormatting.base.formatText(killHour)) @@ -272,10 +282,14 @@ object GhostCounter { if (notifyCTModule && ProfileStorageData.profileSpecific?.ghostCounter?.ctDataImported != true) { notifyCTModule = false if (isUsingCTGhostCounter()) { - clickableChat("§6[SkyHanni] GhostCounterV3 ChatTriggers module has been detected, do you want to import saved data ? Click here to import data", "shimportghostcounterdata") + clickableChat( + "§6[SkyHanni] GhostCounterV3 ChatTriggers module has been detected, do you want to import saved data ? Click here to import data", + "shimportghostcounterdata" + ) } } - inMist = Minecraft.getMinecraft().thePlayer.posY <= 110 // some area don't show as 'The Mist' in the scoreboard + // some area don't show as 'The Mist' in the scoreboard + inMist = Minecraft.getMinecraft().thePlayer.posY <= 110 update() } if (event.repeatSeconds(2)) { @@ -308,8 +322,9 @@ object GhostCounter { var parse = true if (skillPercent) { percent = nf.parse(group("percent")).toFloat() - val level = if (currentSkill == "Combat" && currentSkillLevel != -1) currentSkillLevel else XPInformation.getInstance().getSkillInfo(skillName)?.level - ?: 0 + val level = + if (currentSkill == "Combat" && currentSkillLevel != -1) currentSkillLevel else XPInformation.getInstance() + .getSkillInfo(skillName)?.level ?: 0 if (level > 0) { totalSkillXp = SkillExperience.getExpForNextLevel(level) currentSkillXp = totalSkillXp * percent / 100 @@ -433,7 +448,8 @@ object GhostCounter { if (inventoryName != "Bestiary ➜ Dwarven Mines") return val stacks = event.inventoryItems val ghostStack = stacks[10] ?: return - val bestiaryNextLevel = if (ghostStack.displayName == "§cGhost") 1 else ghostStack.displayName.substring(8).romanToDecimal() + 1 + val bestiaryNextLevel = + if (ghostStack.displayName == "§cGhost") 1 else ghostStack.displayName.substring(8).romanToDecimal() + 1 hidden?.bestiaryNextLevel = bestiaryNextLevel.toDouble() var kills = 0.0 for (line in ghostStack.getLore()) { @@ -454,7 +470,7 @@ object GhostCounter { if (hidden?.configUpdateVersion == 0) { config.textFormatting.bestiaryFormatting.base = " &6Bestiary %display%: &b%value%" chat("§e[SkyHanni] Your GhostCounter config has been automatically adjusted.") - hidden?.configUpdateVersion = configUpdateVersion + hidden?.configUpdateVersion = CONFIG_VALUE_VERSION } } |