From 8dfbcf2a67f0a8207e49d8a97e18c4e80f8fbb96 Mon Sep 17 00:00:00 2001 From: HiZe Date: Sat, 24 Feb 2024 17:25:08 +0100 Subject: Feature: Skill progress display (#957) Co-authored-by: Thunderblade73 Co-authored-by: superhize Co-authored-by: Cal Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com> --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 6 + .../java/at/hannibal2/skyhanni/api/SkillAPI.kt | 449 ++++++++++++++++++++ .../at/hannibal2/skyhanni/config/Features.java | 5 + .../java/at/hannibal2/skyhanni/config/Storage.java | 5 + .../hannibal2/skyhanni/config/commands/Commands.kt | 31 +- .../skillprogress/AllSkillDisplayConfig.java | 37 ++ .../features/skillprogress/CustomGoalConfig.java | 39 ++ .../skillprogress/SkillETADisplayConfig.java | 44 ++ .../skillprogress/SkillOverflowConfig.java | 46 ++ .../skillprogress/SkillProgressBarConfig.java | 107 +++++ .../skillprogress/SkillProgressConfig.java | 117 +++++ .../at/hannibal2/skyhanni/data/ActionBarData.kt | 7 +- .../skyhanni/events/ActionBarUpdateEvent.kt | 9 +- .../skyhanni/events/SkillOverflowLevelupEvent.kt | 5 + .../features/chroma/ChromaShaderManager.kt | 2 +- .../features/chroma/StandardChromaShader.kt | 2 +- .../features/chroma/TexturedChromaShader.kt | 2 +- .../features/combat/ghostcounter/GhostCounter.kt | 6 +- .../garden/farming/GardenCropMilestoneDisplay.kt | 2 +- .../inventory/ItemDisplayOverlayFeatures.kt | 17 +- .../hannibal2/skyhanni/features/minion/MinionXp.kt | 34 +- .../features/misc/RoundedRectangleShader.kt | 2 +- .../features/skillprogress/SkillProgress.kt | 472 +++++++++++++++++++++ .../features/skillprogress/SkillTooltip.kt | 85 ++++ .../skyhanni/features/skillprogress/SkillType.kt | 36 ++ .../skyhanni/features/skillprogress/SkillUtil.kt | 140 ++++++ .../java/at/hannibal2/skyhanni/utils/ColorUtils.kt | 10 + .../at/hannibal2/skyhanni/utils/GuiRenderUtils.kt | 47 ++ .../at/hannibal2/skyhanni/utils/LorenzUtils.kt | 4 +- .../java/at/hannibal2/skyhanni/utils/NumberUtil.kt | 15 +- src/main/java/at/hannibal2/skyhanni/utils/Quad.kt | 31 ++ .../at/hannibal2/skyhanni/utils/RenderUtils.kt | 2 +- .../skyhanni/utils/renderables/Renderable.kt | 113 +++-- .../at/hannibal2/skyhanni/utils/shader/Shader.kt | 8 +- .../skyhanni/utils/shader/ShaderHelper.kt | 6 +- .../skyhanni/utils/shader/ShaderManager.kt | 10 +- 36 files changed, 1863 insertions(+), 90 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/skillprogress/AllSkillDisplayConfig.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/skillprogress/CustomGoalConfig.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/skillprogress/SkillETADisplayConfig.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/skillprogress/SkillOverflowConfig.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/skillprogress/SkillProgressBarConfig.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/skillprogress/SkillProgressConfig.java create mode 100644 src/main/java/at/hannibal2/skyhanni/events/SkillOverflowLevelupEvent.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillTooltip.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillType.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillUtil.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/utils/Quad.kt (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index de14fd4e4..ac02e25c1 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni import at.hannibal2.skyhanni.api.CollectionAPI import at.hannibal2.skyhanni.api.DataWatcherAPI +import at.hannibal2.skyhanni.api.SkillAPI import at.hannibal2.skyhanni.api.GetFromSackAPI import at.hannibal2.skyhanni.config.ConfigFileType import at.hannibal2.skyhanni.config.ConfigManager @@ -284,6 +285,8 @@ import at.hannibal2.skyhanni.features.misc.items.EstimatedItemValue import at.hannibal2.skyhanni.features.misc.items.EstimatedWardrobePrice import at.hannibal2.skyhanni.features.misc.items.GlowingDroppedItems import at.hannibal2.skyhanni.features.misc.massconfiguration.DefaultConfigFeatures +import at.hannibal2.skyhanni.features.skillprogress.SkillTooltip +import at.hannibal2.skyhanni.features.skillprogress.SkillProgress import at.hannibal2.skyhanni.features.misc.teleportpad.TeleportPadCompactName import at.hannibal2.skyhanni.features.misc.teleportpad.TeleportPadInventoryNumber import at.hannibal2.skyhanni.features.misc.trevor.TrevorFeatures @@ -473,6 +476,7 @@ class SkyHanniMod { loadModule(SackAPI) loadModule(BingoAPI) loadModule(FishingAPI) + loadModule(SkillAPI) loadModule(IsFishingDetection) loadModule(LorenzUtils) loadModule(NEUItems) @@ -747,6 +751,8 @@ class SkyHanniMod { loadModule(SulphurSkitterBox()) loadModule(HighlightInquisitors()) loadModule(VerminTracker) + loadModule(SkillProgress) + loadModule(SkillTooltip()) loadModule(QuiverNotification) init() diff --git a/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt new file mode 100644 index 000000000..63b9236de --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/api/SkillAPI.kt @@ -0,0 +1,449 @@ +package at.hannibal2.skyhanni.api + +import at.hannibal2.skyhanni.data.ProfileStorageData +import at.hannibal2.skyhanni.events.ActionBarUpdateEvent +import at.hannibal2.skyhanni.events.ConfigLoadEvent +import at.hannibal2.skyhanni.events.DebugDataCollectEvent +import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent +import at.hannibal2.skyhanni.events.SkillOverflowLevelupEvent +import at.hannibal2.skyhanni.features.skillprogress.SkillProgress +import at.hannibal2.skyhanni.features.skillprogress.SkillType +import at.hannibal2.skyhanni.features.skillprogress.SkillUtil.SPACE_SPLITTER +import at.hannibal2.skyhanni.features.skillprogress.SkillUtil.XP_NEEDED_FOR_60 +import at.hannibal2.skyhanni.features.skillprogress.SkillUtil.calculateLevelXp +import at.hannibal2.skyhanni.features.skillprogress.SkillUtil.calculateOverFlow +import at.hannibal2.skyhanni.features.skillprogress.SkillUtil.getLevel +import at.hannibal2.skyhanni.features.skillprogress.SkillUtil.getLevelExact +import at.hannibal2.skyhanni.features.skillprogress.SkillUtil.getSkillInfo +import at.hannibal2.skyhanni.features.skillprogress.SkillUtil.levelArray +import at.hannibal2.skyhanni.features.skillprogress.SkillUtil.xpRequiredForLevel +import at.hannibal2.skyhanni.utils.ChatUtils +import at.hannibal2.skyhanni.utils.ChatUtils.userError +import at.hannibal2.skyhanni.utils.ItemUtils.cleanName +import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber +import at.hannibal2.skyhanni.utils.NumberUtil.romanToDecimalIfNecessary +import at.hannibal2.skyhanni.utils.SimpleTimeMark +import at.hannibal2.skyhanni.utils.StringUtils.removeColor +import at.hannibal2.skyhanni.utils.TabListData +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import com.google.gson.GsonBuilder +import com.google.gson.annotations.Expose +import com.google.gson.reflect.TypeToken +import io.github.moulberry.notenoughupdates.util.Constants +import io.github.moulberry.notenoughupdates.util.Utils +import net.minecraft.command.CommandBase +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.util.LinkedList +import java.util.regex.Matcher +import kotlin.concurrent.fixedRateTimer +import kotlin.time.Duration.Companion.seconds + +object SkillAPI { + private val patternGroup = RepoPattern.group("api.skilldisplay") + private val skillPercentPattern by patternGroup.pattern( + "skill.percent", + "\\+(?[\\d.,]+) (?.+) \\((?[\\d.]+)%\\)" + ) + private val skillPattern by patternGroup.pattern( + "skill", + "\\+(?[\\d.,]+) (?\\w+) \\((?[\\d.,]+)/(?[\\d.,]+)\\)" + ) + private val skillMultiplierPattern by patternGroup.pattern( + "skill.multiplier", + "\\+(?[\\d.,]+) (?.+) \\((?[\\d.,]+)/(?[\\d,.]+[kmb])\\)" + ) + private val skillTabPattern by patternGroup.pattern( + "skill.tab", + "^§e§lSkills: §r§a(?\\w+) (?\\d+): §r§3(?.+)%\$" + ) + private val maxSkillTabPattern by patternGroup.pattern( + "skill.tab.max", + "^§e§lSkills: §r§a(?\\w+) (?\\d+): §r§c§lMAX\$" + ) + + var skillXPInfoMap = mutableMapOf() + var oldSkillInfoMap = mutableMapOf() + val storage get() = ProfileStorageData.profileSpecific?.skillData + var exactLevelingMap = mapOf() + var levelingMap = mapOf() + var activeSkill: SkillType? = null + + // TODO Use a map maxSkillLevel and move it into the repo + val excludedSkills = listOf( + SkillType.FORAGING, + SkillType.FISHING, + SkillType.ALCHEMY, + SkillType.CARPENTRY + ) + var showDisplay = false + var lastUpdate = SimpleTimeMark.farPast() + + @SubscribeEvent + fun onActionBar(event: ActionBarUpdateEvent) { + val actionBar = event.actionBar.removeColor() + val components = SPACE_SPLITTER.splitToList(actionBar) + for (component in components) { + val matcher = listOf(skillPattern, skillPercentPattern, skillMultiplierPattern) + .firstOrNull { it.matcher(component).matches() } + ?.matcher(component) + + if (matcher?.matches() == true) { + val skillName = matcher.group("skillName") + val skillType = SkillType.getByNameOrNull(skillName) ?: return + val skillInfo = storage?.get(skillType) ?: SkillInfo() + val skillXp = skillXPInfoMap[skillType] ?: SkillXPInfo() + activeSkill = skillType + when (matcher.pattern()) { + skillPattern -> handleSkillPattern(matcher, skillType, skillInfo) + skillPercentPattern -> handleSkillPatternPercent(matcher, skillType) + skillMultiplierPattern -> handleSkillPatternMultiplier(matcher, skillType, skillInfo) + } + showDisplay = true + lastUpdate = SimpleTimeMark.now() + skillXp.lastUpdate = SimpleTimeMark.now() + skillXp.sessionTimerActive = true + + if (skillXp.shouldStartTimer) { + runTimer(skillName, skillXp) + skillXp.shouldStartTimer = false + } + SkillProgress.updateDisplay() + SkillProgress.hideInActionBar = listOf(component) + return + } + } + } + + @SubscribeEvent + fun onConfigLoad(event: ConfigLoadEvent) { + val gson = GsonBuilder().create() + val xpList: List = gson.fromJson( + Utils.getElement(Constants.LEVELING, "leveling_xp").asJsonArray.toString(), + object : TypeToken>() {}.type + ) + levelingMap = xpList.withIndex().associate { (index, xp) -> index to xp } + exactLevelingMap = xpList.withIndex().associate { (index, xp) -> xp to index } + } + + @SubscribeEvent + fun onInventoryOpen(event: InventoryFullyOpenedEvent) { + val inventoryName = event.inventoryName + for (stack in event.inventoryItems.values) { + val lore = stack.getLore() + if (inventoryName == "Your Skills" && + lore.any { it.contains("Click to view!") || it.contains("Not unlocked!") } + ) { + val cleanName = stack.cleanName() + val split = cleanName.split(" ") + val skillName = split.first() + val skill = SkillType.getByNameOrNull(skillName) ?: continue + val skillLevel = if (split.size > 1) split.last().romanToDecimalIfNecessary() else 0 + val skillInfo = storage?.getOrPut(skill) { SkillInfo() } + + for ((lineIndex, line) in lore.withIndex()) { + val cleanLine = line.removeColor() + if (!cleanLine.startsWith(" ")) continue + val previousLine = stack.getLore()[lineIndex - 1] + val progress = cleanLine.substring(cleanLine.lastIndexOf(' ') + 1) + if (previousLine == "§7§8Max Skill level reached!") { + var totalXp = progress.formatNumber() + val minus = if (skillLevel == 50) 4_000_000 else if (skillLevel == 60) 7_000_000 else 0 + totalXp -= minus + val (overflowLevel, overflowCurrent, overflowNeeded, overflowTotal) = getSkillInfo(skillLevel, totalXp, 0L, totalXp) + skillInfo?.apply { + this.overflowLevel = overflowLevel + this.overflowCurrentXp = overflowCurrent + this.overflowCurrentXpMax = overflowNeeded + this.overflowTotalXp = overflowTotal + + this.totalXp = totalXp + this.level = skillLevel + this.currentXp = totalXp + this.currentXpMax = 0L + } + } else { + val splitProgress = progress.split("/") + val currentXp = splitProgress.first().formatNumber() + val neededXp = splitProgress.last().formatNumber() + val levelingArray = levelArray() + val levelXp = calculateLevelXp(levelingArray, skillLevel - 1).toLong() + + skillInfo?.apply { + this.currentXp = currentXp + this.level = skillLevel + this.currentXpMax = neededXp + this.totalXp = levelXp + currentXp + + this.overflowCurrentXp = currentXp + this.overflowLevel = skillLevel + this.overflowCurrentXpMax = neededXp + this.overflowTotalXp = levelXp + currentXp + } + } + } + } + } + } + + @SubscribeEvent + fun onDebugDataCollect(event: DebugDataCollectEvent) { + event.title("Skills") + val storage = storage + if (storage == null) { + event.addIrrelevant("SkillMap is empty") + return + } + event.addData { + for ((skillName, skillInfo) in storage) { + add("- Name: $skillName") + add("- Level: ${skillInfo.level}") + add("- CurrentXp: ${skillInfo.currentXp}") + add("- CurrentXpMax: ${skillInfo.currentXpMax}") + add("- TotalXp: ${skillInfo.totalXp}") + add("- OverflowLevel: ${skillInfo.overflowLevel}") + add("- OverflowCurrentXp: ${skillInfo.overflowCurrentXp}") + add("- OverflowCurrentXpMax: ${skillInfo.overflowCurrentXpMax}") + add("- OverflowTotalXp: ${skillInfo.overflowTotalXp}") + add("- CustomGoalLevel: ${skillInfo.customGoalLevel}\n") + } + + } + } + + private fun runTimer(skillName: String, info: SkillXPInfo) { + fixedRateTimer(name = "skyhanni-skillprogress-timer-$skillName", initialDelay = 1_000L, period = 1_000L) { + if (info.shouldStartTimer) cancel() + val time = when (activeSkill) { + SkillType.FARMING -> SkillProgress.etaConfig.farmingPauseTime + SkillType.MINING -> SkillProgress.etaConfig.miningPauseTime + SkillType.COMBAT -> SkillProgress.etaConfig.combatPauseTime + SkillType.FORAGING -> SkillProgress.etaConfig.foragingPauseTime + SkillType.FISHING -> SkillProgress.etaConfig.fishingPauseTime + else -> 0 + } + if (info.lastUpdate.passedSince() > time.seconds) { + info.sessionTimerActive = false + } + if (info.sessionTimerActive) { + info.timeActive++ + } + } + } + + private fun handleSkillPattern(matcher: Matcher, skillType: SkillType, skillInfo: SkillInfo) { + val currentXp = matcher.group("current").formatNumber() + val maxXp = matcher.group("needed").formatNumber() + val level = getLevelExact(maxXp) + + val (levelOverflow, currentOverflow, currentMaxOverflow, totalOverflow) = getSkillInfo(level, currentXp, maxXp, currentXp) + if (skillInfo.overflowLevel != 0 && levelOverflow == skillInfo.overflowLevel + 1) + SkillOverflowLevelupEvent(skillType, skillInfo.overflowLevel, levelOverflow).postAndCatch() + + skillInfo.apply { + this.level = level + this.currentXp = currentXp + this.currentXpMax = maxXp + this.totalXp = currentXp + + this.overflowLevel = levelOverflow + this.overflowCurrentXp = currentOverflow + this.overflowCurrentXpMax = currentMaxOverflow + this.overflowTotalXp = totalOverflow + + this.lastGain = matcher.group("gained") + } + storage?.set(skillType, skillInfo) + } + + private fun handleSkillPatternPercent(matcher: Matcher, skillType: SkillType) { + var tablistLevel = 0 + for (line in TabListData.getTabList()) { + var levelMatcher = skillTabPattern.matcher(line) + if (levelMatcher.matches()) { + tablistLevel = levelMatcher.group("level").toInt() + if (levelMatcher.group("type").lowercase() != activeSkill?.lowercaseName) tablistLevel = 0 + } else { + levelMatcher = maxSkillTabPattern.matcher(line) + if (levelMatcher.matches()) { + tablistLevel = levelMatcher.group("level").toInt() + if (levelMatcher.group("type").lowercase() != activeSkill?.lowercaseName) tablistLevel = 0 + } + } + } + val existingLevel = getSkillInfo(skillType) ?: SkillInfo() + val xpPercentageS = matcher.group("progress").replace(",", "") + val xpPercentage = xpPercentageS.toFloatOrNull() ?: return + val levelingArray = levelArray() + val levelXp = calculateLevelXp(levelingArray, existingLevel.level - 1) + val nextLevelDiff = levelingArray[tablistLevel]?.asDouble ?: 7_600_000.0 + val nextLevelProgress = nextLevelDiff * xpPercentage / 100 + val totalXp = levelXp + nextLevelProgress + val (_, currentOverflow, currentMaxOverflow, totalOverflow) = getSkillInfo(tablistLevel, nextLevelProgress.toLong(), nextLevelDiff.toLong(), totalXp.toLong()) + existingLevel.apply { + this.totalXp = totalXp.toLong() + this.currentXp = nextLevelProgress.toLong() + this.currentXpMax = nextLevelDiff.toLong() + this.level = tablistLevel + + this.overflowTotalXp = totalOverflow + this.overflowCurrentXp = currentOverflow + this.overflowCurrentXpMax = currentMaxOverflow + this.overflowLevel = tablistLevel + + this.lastGain = matcher.group("gained") + } + storage?.set(skillType, existingLevel) + } + + private fun handleSkillPatternMultiplier(matcher: Matcher, skillType: SkillType, skillInfo: SkillInfo) { + val currentXp = matcher.group("current").formatNumber() + val maxXp = matcher.group("needed").formatNumber() + val level = getLevelExact(maxXp) + val levelingArray = levelArray() + val levelXp = calculateLevelXp(levelingArray, level - 1).toLong() + currentXp + val (currentLevel, currentOverflow, currentMaxOverflow, totalOverflow) = getSkillInfo(level, currentXp, maxXp, levelXp) + skillInfo.apply { + this.overflowCurrentXp = currentOverflow + this.overflowCurrentXpMax = currentMaxOverflow + this.overflowTotalXp = totalOverflow + this.overflowLevel = currentLevel + + this.currentXp = currentXp + this.currentXpMax = maxXp + this.totalXp = levelXp + this.level = level + + this.lastGain = matcher.group("gained") + } + storage?.set(skillType, skillInfo) + } + + fun onCommand(it: Array) { + if (it.isEmpty()) { + commandHelp() + return + } + + val first = it.first() + if (it.size == 1) { + when (first) { + "skillgoal" -> { + ChatUtils.chat("§bSkill Custom Goal Level") + if (storage?.isEmpty() == true) { + ChatUtils.chat("§cYou haven't set any custom goal yet!") + } + storage?.filter { it.value.customGoalLevel != 0 }?.forEach { (skill, data) -> + ChatUtils.chat("§e${skill.displayName}: §b${data.customGoalLevel}") + } + } + } + } + + if (it.size == 2) { + val second = it[1] + when (first) { + "levelwithxp" -> { + val xp = second.toLong() + if (xp <= XP_NEEDED_FOR_60) { + val level = getLevel(xp) + ChatUtils.chat("With §b${xp.addSeparators()} §eXP you would be level §b$level") + } else { + val (overflowLevel, current, needed, _) = calculateOverFlow(second.toLong()) + ChatUtils.chat("With §b${xp.addSeparators()} §eXP you would be level §b$overflowLevel " + + "§ewith progress (§b${current.addSeparators()}§e/§b${needed.addSeparators()}§e) XP") + } + } + + "xpforlevel" -> { + val level = second.toInt() + if (level <= 60) { + val neededXp = levelingMap.filter { it.key < level }.values.sum().toLong() + ChatUtils.chat("You need §b${neededXp.addSeparators()} §eXP to be level §b${level.toDouble()}") + } else { + val base = levelingMap.values.sum().toLong() + val neededXP = xpRequiredForLevel(level.toDouble()) + base + ChatUtils.chat("You need §b${neededXP.addSeparators()} §eXP to be level §b${level.toDouble()}") + } + + } + } + } + if (it.size == 3) { + when (first) { + "skillgoal" -> { + val rawSkill = it[1].lowercase() + val skillType = SkillType.getByNameOrNull(rawSkill) + if (skillType == null) { + userError("Unknown Skill type: $rawSkill") + return + } + val rawLevel = it[2] + val targetLevel = rawLevel.toIntOrNull() + if (targetLevel == null) { + userError("$rawLevel is not a valid number.") + return + } + val skill = storage?.get(skillType) ?: return + + if (targetLevel <= skill.overflowLevel && targetLevel != 0) { + userError("Custom goal level ($targetLevel) must be greater than your current level (${skill.overflowLevel}).") + return + } + + skill.customGoalLevel = targetLevel + ChatUtils.chat("Custom goal level for §b${skillType.displayName} §eset to §b$targetLevel") + } + } + } + } + + fun onComplete(strings: Array): List { + return when (strings.size) { + 1 -> listOf("levelwithxp", "xpforlevel", "skillgoal") + 2 -> if (strings[0].lowercase() == "skillgoal") CommandBase.getListOfStringsMatchingLastWord( + strings, + SkillType.entries.map { it.displayName }) + else + listOf() + + else -> listOf() + } + } + + private fun commandHelp() { + ChatUtils.chat("", false) + ChatUtils.chat("§6/shskills levelwithxp - §bGet a level with the given current XP.", false) + ChatUtils.chat("§6/shskills xpforlevel - §bGet how much XP you need for a desired level.", false) + ChatUtils.chat("§6/shskills skillgoal - §bView your current goal", false) + ChatUtils.chat("§6/shskills skillgoal - §bDefine your goal for ", false) + ChatUtils.chat("", false) + } + + data class SkillInfo( + @Expose var level: Int = 0, + @Expose var totalXp: Long = 0, + @Expose var currentXp: Long = 0, + @Expose var currentXpMax: Long = 0, + @Expose var overflowLevel: Int = 0, + @Expose var overflowCurrentXp: Long = 0, + @Expose var overflowTotalXp: Long = 0, + @Expose var overflowCurrentXpMax: Long = 0, + @Expose var lastGain: String = "", + @Expose var customGoalLevel: Int = 0, + ) + + data class SkillXPInfo( + var lastTotalXp: Float = 0f, + var xpGainQueue: LinkedList = LinkedList(), + var xpGainHour: Float = 0f, + var xpGainLast: Float = 0f, + var timer: Int = 3, + var sessionTimerActive: Boolean = false, + var isActive: Boolean = false, + var lastUpdate: SimpleTimeMark = SimpleTimeMark.farPast(), + var timeActive: Long = 0L, + var shouldStartTimer: Boolean = true, + ) +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/Features.java b/src/main/java/at/hannibal2/skyhanni/config/Features.java index ded615520..af464f366 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Features.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Features.java @@ -21,6 +21,7 @@ import at.hannibal2.skyhanni.config.features.mining.MiningConfig; import at.hannibal2.skyhanni.config.features.minion.MinionsConfig; import at.hannibal2.skyhanni.config.features.misc.MiscConfig; import at.hannibal2.skyhanni.config.features.rift.RiftConfig; +import at.hannibal2.skyhanni.config.features.skillprogress.SkillProgressConfig; import at.hannibal2.skyhanni.config.features.slayer.SlayerConfig; import at.hannibal2.skyhanni.config.features.stranded.StrandedConfig; import com.google.gson.annotations.Expose; @@ -136,6 +137,10 @@ public class Features extends Config { @Category(name = "Mining", desc = "Features that help you break blocks.") public MiningConfig mining = new MiningConfig(); + @Expose + @Category(name = "Skill Progress", desc = "Skill Progress related config options.") + public SkillProgressConfig skillProgress = new SkillProgressConfig(); + @Expose @Category(name = "Slayer", desc = "Slayer features.") public SlayerConfig slayer = new SlayerConfig(); diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java index 77b92131b..fe303a17e 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java @@ -1,5 +1,6 @@ package at.hannibal2.skyhanni.config; +import at.hannibal2.skyhanni.api.SkillAPI; import at.hannibal2.skyhanni.data.model.ComposterUpgrade; import at.hannibal2.skyhanni.features.bingo.card.goals.BingoGoal; import at.hannibal2.skyhanni.features.combat.endernodetracker.EnderNodeTracker; @@ -23,6 +24,7 @@ import at.hannibal2.skyhanni.features.misc.trevor.TrevorTracker; import at.hannibal2.skyhanni.features.misc.visualwords.VisualWord; import at.hannibal2.skyhanni.features.rift.area.westvillage.VerminTracker; import at.hannibal2.skyhanni.features.rift.area.westvillage.kloon.KloonTerminal; +import at.hannibal2.skyhanni.features.skillprogress.SkillType; import at.hannibal2.skyhanni.features.slayer.SlayerProfitTracker; import at.hannibal2.skyhanni.utils.LorenzVec; import at.hannibal2.skyhanni.utils.NEUInternalName; @@ -471,5 +473,8 @@ public class Storage { // TODO renmae public MythologicalCreatureTracker.Data mythologicalMobTracker = new MythologicalCreatureTracker.Data(); } + + @Expose + public Map skillData = new HashMap<>(); } } 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 680834317..ee89b5720 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.config.commands import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.SkillAPI import at.hannibal2.skyhanni.config.ConfigFileType import at.hannibal2.skyhanni.config.ConfigGuiManager import at.hannibal2.skyhanni.data.ChatManager @@ -14,6 +15,7 @@ import at.hannibal2.skyhanni.features.chat.Translator import at.hannibal2.skyhanni.features.combat.endernodetracker.EnderNodeTracker import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil import at.hannibal2.skyhanni.features.commands.PartyCommands +import at.hannibal2.skyhanni.features.commands.WikiManager import at.hannibal2.skyhanni.features.event.diana.AllBurrowsList import at.hannibal2.skyhanni.features.event.diana.BurrowWarpHelper import at.hannibal2.skyhanni.features.event.diana.DianaProfitTracker @@ -240,6 +242,33 @@ object Commands { "shresetseacreaturetracker", "Resets the Sea Creature Tracker" ) { SeaCreatureTracker.resetCommand(it) } + registerCommand( + "shfandomwiki", + "Searches the fandom wiki with SkyHanni's own method." + ) { WikiManager.otherWikiCommands(it, true) } + registerCommand( + "shfandomwikithis", + "Searches the fandom wiki with SkyHanni's own method." + ) { WikiManager.otherWikiCommands(it, true, true) } + registerCommand( + "shofficialwiki", + "Searches the official wiki with SkyHanni's own method." + ) { WikiManager.otherWikiCommands(it, false) } + registerCommand( + "shofficialwikithis", + "Searches the official wiki with SkyHanni's own method." + ) { WikiManager.otherWikiCommands(it, false, true) } + registerCommand0("shcalccrop", "Calculate how many crops need to be farmed between different crop milestones.", { + FarmingMilestoneCommand.onCommand(it.getOrNull(0), it.getOrNull(1), it.getOrNull(2), false) + }, FarmingMilestoneCommand::onComplete) + registerCommand0("shcalccroptime", "Calculate how long you need to farm crops between different crop milestones.", { + FarmingMilestoneCommand.onCommand(it.getOrNull(0), it.getOrNull(1), it.getOrNull(2), true) + }, FarmingMilestoneCommand::onComplete) + registerCommand0( + "shskills", + "Skills XP/Level related command", + { SkillAPI.onCommand(it) }, + SkillAPI::onComplete) registerCommand0( "shcalccrop", "Calculate how many crops need to be farmed between different crop milestones.", @@ -549,4 +578,4 @@ object Commands { if (args != null) function(args.asList().toTypedArray()) } } -} +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/skillprogress/AllSkillDisplayConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/skillprogress/AllSkillDisplayConfig.java new file mode 100644 index 000000000..081a022db --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/skillprogress/AllSkillDisplayConfig.java @@ -0,0 +1,37 @@ +package at.hannibal2.skyhanni.config.features.skillprogress; + +import at.hannibal2.skyhanni.config.FeatureToggle; +import at.hannibal2.skyhanni.features.skillprogress.SkillType; +import com.google.gson.annotations.Expose; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDraggableList; +import io.github.moulberry.moulconfig.annotations.ConfigOption; +import io.github.moulberry.moulconfig.observer.Property; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class AllSkillDisplayConfig { + + @Expose + @ConfigOption(name = "Enabled", desc = "Show a display with all skills progress.") + @ConfigEditorBoolean + @FeatureToggle + public Property enabled = Property.of(false); + + @Expose + @ConfigOption(name = "Text", desc = "Choose what skills you want to see in the display.") + @ConfigEditorDraggableList + public List skillEntryList = new ArrayList<>(Arrays.asList( + SkillType.COMBAT, + SkillType.FARMING, + SkillType.FISHING, + SkillType.MINING, + SkillType.FORAGING, + SkillType.ENCHANTING, + SkillType.ALCHEMY, + SkillType.CARPENTRY, + SkillType.TAMING + )); +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/skillprogress/CustomGoalConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/skillprogress/CustomGoalConfig.java new file mode 100644 index 000000000..9d645c8c7 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/skillprogress/CustomGoalConfig.java @@ -0,0 +1,39 @@ +package at.hannibal2.skyhanni.config.features.skillprogress; + +import com.google.gson.annotations.Expose; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigOption; + +public class CustomGoalConfig { + + @Expose + @ConfigOption(name = "Display", desc = "Enable the custom goal in the progress display.") + @ConfigEditorBoolean + public boolean enableInDisplay = true; + + @Expose + @ConfigOption(name = "All Skill Display", desc = "Enable the custom goal in the all skill display.") + @ConfigEditorBoolean + public boolean enableInAllDisplay = false; + + @Expose + @ConfigOption(name = "ETA Display", desc = "Enable the custom goal in the ETA skill display.") + @ConfigEditorBoolean + public boolean enableInETADisplay = false; + + @Expose + @ConfigOption(name = "Progress Bar", desc = "Enable the custom goal in the progress bar.") + @ConfigEditorBoolean + public boolean enableInProgressBar = true; + + @Expose + @ConfigOption(name = "Skill Menu Tooltips", desc = "Enable the custom goal in the tooltip of items in skills menu.") + @ConfigEditorBoolean + public boolean enableInSkillMenuTooltip = false; + + @Expose + @ConfigOption(name = "Chat", desc = "Send a message when you reach your goal.") + @ConfigEditorBoolean + public boolean enableInChat = false; + +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/skillprogress/SkillETADisplayConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/skillprogress/SkillETADisplayConfig.java new file mode 100644 index 000000000..37ea0430c --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/skillprogress/SkillETADisplayConfig.java @@ -0,0 +1,44 @@ +package at.hannibal2.skyhanni.config.features.skillprogress; + +import at.hannibal2.skyhanni.config.FeatureToggle; +import com.google.gson.annotations.Expose; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; +import io.github.moulberry.moulconfig.annotations.ConfigEditorText; +import io.github.moulberry.moulconfig.annotations.ConfigOption; +import io.github.moulberry.moulconfig.observer.Property; + +public class SkillETADisplayConfig { + + @Expose + @ConfigOption(name = "Enabled", desc = "Show a display of your current active skill\n" + + "with the XP/hour rate, ETA to the next level and current session time.") + @ConfigEditorBoolean + @FeatureToggle + public Property enabled = Property.of(false); + + @Expose + @ConfigOption(name = "Farming", desc = "After how much seconds the Farming session timer should pause.") + @ConfigEditorSlider(minStep = 1, minValue = 3, maxValue = 60) + public int farmingPauseTime = 3; + + @Expose + @ConfigOption(name = "Mining", desc = "After how much seconds the Mining session timer should pause.") + @ConfigEditorSlider(minStep = 1, minValue = 3, maxValue = 60) + public int miningPauseTime = 3; + + @Expose + @ConfigOption(name = "Combat", desc = "After how much seconds the Combat session timer should pause.") + @ConfigEditorSlider(minStep = 1, minValue = 3, maxValue = 60) + public int combatPauseTime = 30; + + @Expose + @ConfigOption(name = "Foraging", desc = "After how much seconds the Foraging session timer should pause.") + @ConfigEditorSlider(minStep = 1, minValue = 3, maxValue = 60) + public int foragingPauseTime = 3; + + @Expose + @ConfigOption(name = "Fishing", desc = "After how much seconds the Fishing session timer should pause.") + @ConfigEditorSlider(minStep = 1, minValue = 3, maxValue = 60) + public int fishingPauseTime = 15; +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/skillprogress/SkillOverflowConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/skillprogress/SkillOverflowConfig.java new file mode 100644 index 000000000..cf6118158 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/skillprogress/SkillOverflowConfig.java @@ -0,0 +1,46 @@ +package at.hannibal2.skyhanni.config.features.skillprogress; + +import com.google.gson.annotations.Expose; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigOption; +import io.github.moulberry.moulconfig.observer.Property; + +public class SkillOverflowConfig { + + @Expose + @ConfigOption(name = "Display", desc = "Enable the overflow calculation in the progress display.") + @ConfigEditorBoolean + public Property enableInDisplay = Property.of(false); + + @Expose + @ConfigOption(name = "All Skill Display", desc = "Enable the overflow calculation in the all skill progress display.") + @ConfigEditorBoolean + public Property enableInAllDisplay = Property.of(false); + + @Expose + @ConfigOption(name = "ETA Display", desc = "Enable the overflow calculation in the ETA skill display.") + @ConfigEditorBoolean + public Property enableInEtaDisplay = Property.of(false); + + @Expose + @ConfigOption(name = "Progress Bar", desc = "Enable the overflow calculation in the progress bar of the display.") + @ConfigEditorBoolean + public Property enableInProgressBar = Property.of(false); + + @Expose + @ConfigOption(name = "Skill Menu Stack Size", desc = "Enable the overflow calculation when the 'Skill Level' Item Number is enabled.") + @ConfigEditorBoolean + public boolean enableInSkillMenuAsStackSize = false; + + @Expose + @ConfigOption(name = "Skill Menu Tooltips", desc = "Enable the overflow calculation in the tooltip of items in skills menu.") + @ConfigEditorBoolean + public boolean enableInSkillMenuTooltip = false; + + @Expose + @ConfigOption(name = "Chat", desc = "Enable the overflow level up message when you gain an overflow level.") + @ConfigEditorBoolean + public boolean enableInChat = false; + + +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/skillprogress/SkillProgressBarConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/skillprogress/SkillProgressBarConfig.java new file mode 100644 index 000000000..80fe33148 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/skillprogress/SkillProgressBarConfig.java @@ -0,0 +1,107 @@ +package at.hannibal2.skyhanni.config.features.skillprogress; + +import at.hannibal2.skyhanni.SkyHanniMod; +import at.hannibal2.skyhanni.config.FeatureToggle; +import com.google.gson.annotations.Expose; +import io.github.moulberry.moulconfig.annotations.Accordion; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorColour; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; +import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; +import io.github.moulberry.moulconfig.annotations.ConfigOption; +import io.github.moulberry.moulconfig.observer.Property; + +public class SkillProgressBarConfig { + + @Expose + @ConfigOption(name = "Enabled", desc = "Enable/Disable the progress bar.") + @ConfigEditorBoolean + @FeatureToggle + public Property enabled = Property.of(false); + + @Expose + @ConfigOption(name = "Textured Bar", desc = "Use a textured progress bar.\n§eCan be changed with a resource pack.") + @ConfigEditorBoolean + public Property useTexturedBar = Property.of(false); + + @Expose + @ConfigOption(name = "Chroma", desc = "Use the SBA like chroma effect on the bar.\n§eIf enabled, ignore the Bar Color setting.") + @ConfigEditorBoolean + public Property useChroma = Property.of(false); + + @Expose + @ConfigOption(name = "Bar Color", desc = "Color of the progress bar.\n§eIgnored if Chroma is enabled.") + @ConfigEditorColour + public String barStartColor = "0:255:255:0:0"; + + @Expose + @ConfigOption(name = "Textured Bar", desc = "") + @Accordion + public TexturedBar texturedBar = new TexturedBar(); + + public static class TexturedBar { + + @Expose + @ConfigOption(name = "Used Texture", desc = "Choose what texture to use.") + @ConfigEditorDropdown + public Property usedTexture = Property.of(UsedTexture.MATCH_PACK); + + public enum UsedTexture { + MATCH_PACK("Match Resource Pack", "minecraft:textures/gui/icons.png"), + CUSTOM_1("Texture 1", SkyHanniMod.MODID + ":bars/1.png"), + CUSTOM_2("Texture 2", SkyHanniMod.MODID + ":bars/2.png"), + CUSTOM_3("Texture 3", SkyHanniMod.MODID + ":bars/3.png"), + CUSTOM_4("Texture 4", SkyHanniMod.MODID + ":bars/4.png"), + CUSTOM_5("Texture 5", SkyHanniMod.MODID + ":bars/5.png"), + ; + + private final String str; + private final String path; + + UsedTexture(String str, String path) { + this.str = str; + this.path = path; + } + + public String getPath() { + return path; + } + + @Override + public String toString() { + return str; + } + } + + @Expose + @ConfigOption(name = "Width", desc = "Modify the width of the bar.\n" + + "§eDefault: 182\n" + + "§c!!Do not work for now!!") + @ConfigEditorSlider(minStep = 1, minValue = 16, maxValue = 1024) + public int width = 182; + + @Expose + @ConfigOption(name = "Height", desc = "Modify the height of the bar.\n" + + "§eDefault: 5\n" + + "§c!!Do not work for now!!") + @ConfigEditorSlider(minStep = 1, minValue = 3, maxValue = 16) + public int height = 5; + } + + @Expose + @ConfigOption(name = "Regular Bar", desc = "") + @Accordion + public RegularBar regularBar = new RegularBar(); + + public static class RegularBar { + @Expose + @ConfigOption(name = "Width", desc = "Modify the width of the bar.") + @ConfigEditorSlider(minStep = 1, minValue = 100, maxValue = 1000) + public int width = 182; + + @Expose + @ConfigOption(name = "Height", desc = "Modify the height of the bar.") + @ConfigEditorSlider(minStep = 1, minValue = 3, maxValue = 15) + public int height = 6; + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/skillprogress/SkillProgressConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/skillprogress/SkillProgressConfig.java new file mode 100644 index 000000000..77d459b6e --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/skillprogress/SkillProgressConfig.java @@ -0,0 +1,117 @@ +package at.hannibal2.skyhanni.config.features.skillprogress; + +import at.hannibal2.skyhanni.config.FeatureToggle; +import at.hannibal2.skyhanni.config.core.config.Position; +import at.hannibal2.skyhanni.utils.RenderUtils; +import com.google.gson.annotations.Expose; +import io.github.moulberry.moulconfig.annotations.Category; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; +import io.github.moulberry.moulconfig.annotations.ConfigOption; +import io.github.moulberry.moulconfig.observer.Property; + +public class SkillProgressConfig { + + @Expose + @ConfigOption(name = "Enabled", desc = "Show the Skill Progress Display.") + @ConfigEditorBoolean + @FeatureToggle + public Property enabled = Property.of(false); + + @Expose + @ConfigOption(name = "Text Alignment", desc = "Align the display text with the progress bar.") + @ConfigEditorDropdown + public Property textAlignmentProperty = Property.of(TextAlignment.CENTERED); + + public enum TextAlignment { + NONE("None", null), + CENTERED("Centered", RenderUtils.HorizontalAlignment.CENTER), + LEFT("Left", RenderUtils.HorizontalAlignment.LEFT), + RIGHT("Right", RenderUtils.HorizontalAlignment.RIGHT), + ; + + private final String str; + private final RenderUtils.HorizontalAlignment alignment; + + TextAlignment(String str, RenderUtils.HorizontalAlignment alignment) { + this.str = str; + this.alignment = alignment; + } + + public RenderUtils.HorizontalAlignment getAlignment() { + return alignment; + } + + @Override + public String toString() { + return str; + } + } + + @Expose + @ConfigOption(name = "Hide In Action Bar", desc = "Hide the skill progress in the Hypixel action bar.") + @ConfigEditorBoolean + public boolean hideInActionBar = false; + + @Expose + @ConfigOption(name = "Always Show", desc = "Always show the skill progress.") + @ConfigEditorBoolean + public Property alwaysShow = Property.of(false); + + @Expose + @ConfigOption(name = "Show Action left", desc = "Show action left until you reach the next level.") + @ConfigEditorBoolean + public Property showActionLeft = Property.of(false); + + @Expose + @ConfigOption(name = "Use percentage", desc = "Use percentage instead of XP.") + @ConfigEditorBoolean + public Property usePercentage = Property.of(false); + + @Expose + @ConfigOption(name = "Use Icon", desc = "Show the skill icon in the display.") + @ConfigEditorBoolean + public Property useIcon = Property.of(true); + + @Expose + @ConfigOption(name = "Use Skill Name", desc = "Show the skill name in the display.") + @ConfigEditorBoolean + public Property useSkillName = Property.of(false); + + @Expose + @ConfigOption(name = "Show Level", desc = "Show your current level in the display.") + @ConfigEditorBoolean + public Property showLevel = Property.of(true); + + @Expose + @Category(name = "Progress Bar", desc = "Progress Bar Config.") + public SkillProgressBarConfig skillProgressBarConfig = new SkillProgressBarConfig(); + + @Expose + @Category(name = "Overflow", desc = "Overflow Config.") + public SkillOverflowConfig overflowConfig = new SkillOverflowConfig(); + + @Expose + @Category(name = "Custom Goal", desc = "Define a custom goal for each skills.") + public CustomGoalConfig customGoalConfig = new CustomGoalConfig(); + + @Expose + @Category(name = "All Skill Display", desc = "All Skill Display Config.") + public AllSkillDisplayConfig allSkillDisplayConfig = new AllSkillDisplayConfig(); + + @Expose + @Category(name = "ETA Display", desc = "ETA Display Config.") + public SkillETADisplayConfig skillETADisplayConfig = new SkillETADisplayConfig(); + + @Expose + public Position displayPosition = new Position(384, -105, false, true); + + @Expose + public Position barPosition = new Position(384, -87, false, true); + + @Expose + public Position allSkillPosition = new Position(5, 209, false, true); + + @Expose + public Position etaPosition = new Position(5, 155, false, true); +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/ActionBarData.kt b/src/main/java/at/hannibal2/skyhanni/data/ActionBarData.kt index aa72e9868..74617e9b3 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ActionBarData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ActionBarData.kt @@ -22,8 +22,11 @@ object ActionBarData { val original = event.message val message = LorenzUtils.stripVanillaMessage(original.formattedText) - if (message == actionBar) return actionBar = message - ActionBarUpdateEvent(actionBar).postAndCatch() + val actionBarEvent = ActionBarUpdateEvent(actionBar, event.message) + actionBarEvent.postAndCatch() + if (event.message.formattedText != actionBarEvent.chatComponent.formattedText) { + event.message = actionBarEvent.chatComponent + } } } diff --git a/src/main/java/at/hannibal2/skyhanni/events/ActionBarUpdateEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/ActionBarUpdateEvent.kt index 9b9c0f8dd..52ec909c0 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/ActionBarUpdateEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/ActionBarUpdateEvent.kt @@ -1,3 +1,10 @@ package at.hannibal2.skyhanni.events -class ActionBarUpdateEvent(val actionBar: String) : LorenzEvent() +import net.minecraft.util.ChatComponentText +import net.minecraft.util.IChatComponent + +class ActionBarUpdateEvent(var actionBar: String, var chatComponent: IChatComponent) : LorenzEvent() { + fun changeActionBar(newText: String) { + chatComponent = ChatComponentText(newText) + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/events/SkillOverflowLevelupEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/SkillOverflowLevelupEvent.kt new file mode 100644 index 000000000..a4a25a314 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/SkillOverflowLevelupEvent.kt @@ -0,0 +1,5 @@ +package at.hannibal2.skyhanni.events + +import at.hannibal2.skyhanni.features.skillprogress.SkillType + +class SkillOverflowLevelupEvent(val skill: SkillType, val oldLevel: Int, val newLevel: Int): LorenzEvent() diff --git a/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaShaderManager.kt b/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaShaderManager.kt index 98e1daa71..60b748d33 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaShaderManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaShaderManager.kt @@ -54,4 +54,4 @@ enum class ChromaType(val shaderName: String) { * See [TexturedChromaShader] */ TEXTURED("textured_chroma") -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/chroma/StandardChromaShader.kt b/src/main/java/at/hannibal2/skyhanni/features/chroma/StandardChromaShader.kt index 268b37b4c..e1f39aa84 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chroma/StandardChromaShader.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chroma/StandardChromaShader.kt @@ -17,4 +17,4 @@ package at.hannibal2.skyhanni.features.chroma object StandardChromaShader : ChromaShader("standard_chroma", "standard_chroma") { val INSTANCE: StandardChromaShader get() = this -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/chroma/TexturedChromaShader.kt b/src/main/java/at/hannibal2/skyhanni/features/chroma/TexturedChromaShader.kt index 544d10184..26417d8dc 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chroma/TexturedChromaShader.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chroma/TexturedChromaShader.kt @@ -17,4 +17,4 @@ package at.hannibal2.skyhanni.features.chroma object TexturedChromaShader : ChromaShader("textured_chroma", "textured_chroma") { val INSTANCE: TexturedChromaShader get() = this -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt index 733be8cd0..62eff052a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/ghostcounter/GhostCounter.kt @@ -182,7 +182,7 @@ object GhostCounter { val bestiary = if (config.showMax) { when (nextLevel) { 26 -> bestiaryFormatting.maxed.replace("%currentKill%", currentKill.addSeparators()) - in 1..25 -> { + in 1 .. 25 -> { val sum = bestiaryData.filterKeys { it <= nextLevel - 1 }.values.sum() val cKill = sum + currentKill @@ -195,7 +195,7 @@ object GhostCounter { } else { when (nextLevel) { 26 -> bestiaryFormatting.maxed - in 1..25 -> bestiaryFormatting.progress + in 1 .. 25 -> bestiaryFormatting.progress else -> bestiaryFormatting.openMenu } } @@ -301,7 +301,7 @@ object GhostCounter { val res = current.formatNumber().toString() gain = (res.toLong() - lastXp.toLong()).toDouble().roundToInt() num = (gain.toDouble() / gained) - if (gained in 150.0..450.0 && lastXp != "0" && num >= 0) { + if (gained in 150.0 .. 450.0 && lastXp != "0" && num >= 0) { KILLS.add(num) KILLS.add(num, true) Option.GHOSTSINCESORROW.add(num) diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt index b27d3e863..0ac715598 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/GardenCropMilestoneDisplay.kt @@ -147,7 +147,7 @@ object GardenCropMilestoneDisplay { if (crop.isMaxed()) { list.add("§7" + crop.cropName + " §eMAXED") } else { - list.add("§7" + crop.cropName + " $currentTier➜$nextTier") + list.add("§7" + crop.cropName + " §8$currentTier➜§3$nextTier") } lineMap[1] = list diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt index bc3f52ef2..35f0c6f4a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.features.inventory import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.api.CollectionAPI +import at.hannibal2.skyhanni.api.SkillAPI import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumberEntry.BINGO_GOAL_RANK @@ -23,6 +24,7 @@ import at.hannibal2.skyhanni.config.features.inventory.InventoryConfig.ItemNumbe import at.hannibal2.skyhanni.data.PetAPI import at.hannibal2.skyhanni.events.RenderItemTipEvent import at.hannibal2.skyhanni.features.garden.pests.PestAPI +import at.hannibal2.skyhanni.features.skillprogress.SkillType import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemCategory @@ -158,9 +160,14 @@ object ItemDisplayOverlayFeatures { if (CollectionAPI.isCollectionTier0(lore)) return "0" val split = itemName.split(" ") if (!itemName.contains("Dungeon")) { + val skillName = split.first() val text = split.last() if (split.size < 2) return "0" - return "" + text.romanToDecimalIfNecessary() + val level = "" + text.romanToDecimalIfNecessary() + val skill = SkillType.getByNameOrNull(skillName) ?: return level + val skillInfo = SkillAPI.storage?.get(skill) ?: return level + return if (SkyHanniMod.feature.skillProgress.overflowConfig.enableInSkillMenuAsStackSize) + "" + skillInfo.overflowLevel else level } } @@ -205,9 +212,9 @@ object ItemDisplayOverlayFeatures { item.name?.let { dungeonPotionPattern.matchMatcher(it.removeColor()) { return when (val level = group("level").romanToDecimal()) { - in 1..2 -> "§f$level" - in 3..4 -> "§a$level" - in 5..6 -> "§9$level" + in 1 .. 2 -> "§f$level" + in 3 .. 4 -> "§a$level" + in 5 .. 6 -> "§9$level" else -> "§5$level" } } @@ -279,4 +286,4 @@ object ItemDisplayOverlayFeatures { } fun ItemNumberEntry.isSelected() = config.itemNumberAsStackSize.contains(this) -} +} \ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionXp.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionXp.kt index 4d5d54bae..22969de1c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionXp.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionXp.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.events.MinionCloseEvent import at.hannibal2.skyhanni.events.MinionOpenEvent import at.hannibal2.skyhanni.events.MinionStorageOpenEvent import at.hannibal2.skyhanni.events.RepositoryReloadEvent +import at.hannibal2.skyhanni.features.skillprogress.SkillType import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.LorenzUtils @@ -38,28 +39,15 @@ class MinionXp { private var xpInfoMap: Map = hashMapOf() - data class XpInfo(val type: XpType, val amount: Double) - - private data class MinionStorage(val position: LorenzVec, val xpList: EnumMap) { + data class XpInfo(val type: SkillType, val amount: Double) + private data class MinionStorage(val position: LorenzVec, val xpList: EnumMap) { val timestamp: SimpleTimeMark = SimpleTimeMark.now() } private fun toPrimitiveItemStack(itemStack: ItemStack) = PrimitiveItemStack(itemStack.getInternalName(), itemStack.stackSize) - - // TODO use upper case names, created a function to get type by lowercase name - // TODO maybe: rename to SkillType, move somewhere else - enum class XpType { - - Farming, - Mining, - Combat, - Foraging, - Fishing, - Alchemy - } - + @SubscribeEvent fun onMinionOpen(event: MinionOpenEvent) { if (!config.xpDisplay) return @@ -84,7 +72,7 @@ class MinionXp { private fun getStorageXpAndUpdateTotal( minionPosition: LorenzVec, - xpTotal: EnumMap, + xpTotal: EnumMap, ): Boolean { if (!getHasStorage(minionPosition)) return false val storage = minionStorages.firstOrNull { @@ -101,10 +89,10 @@ class MinionXp { } } - private fun handleItems(inventoryItems: Map, isMinion: Boolean): EnumMap { - val xpTotal = EnumMap(XpType::class.java) + private fun handleItems(inventoryItems: Map, isMinion: Boolean): EnumMap { + val xpTotal = EnumMap(SkillType::class.java) inventoryItems.filter { - it.value.getLore().isNotEmpty() && (!isMinion || it.key in listOf(21..26, 30..35, 39..44).flatten()) + it.value.getLore().isNotEmpty() && (!isMinion || it.key in listOf(21 .. 26, 30 .. 35, 39 .. 44).flatten()) }.forEach { (_, itemStack) -> val item = toPrimitiveItemStack(itemStack) val name = item.internalName @@ -133,8 +121,8 @@ class MinionXp { minionStorages.add(MinionStorage(event.position, xpTotal)) } - private fun collectMessage(type: XpType, amount: Double) = - "§7Collect to get: §b${amount.addSeparators()} §e${type.name} XP" + private fun collectMessage(type: SkillType, amount: Double) = + "§7Collect to get: §b${amount.addSeparators()} §e${type.displayName} XP" private fun getHasStorage(minionPosition: LorenzVec): Boolean { val positionsToCheck = listOf( @@ -192,7 +180,7 @@ class MinionXp { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { xpInfoMap = event.getConstant("MinionXP").minion_xp.mapNotNull { xpType -> - xpType.value.mapNotNull { it.key.asInternalName() to XpInfo(XpType.valueOf(xpType.key), it.value) } + xpType.value.mapNotNull { it.key.asInternalName() to XpInfo(SkillType.getByName(xpType.key), it.value) } }.flatten().toMap() } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/RoundedRectangleShader.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/RoundedRectangleShader.kt index 6b0ce5e63..9ce2d0ce7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/RoundedRectangleShader.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/RoundedRectangleShader.kt @@ -25,4 +25,4 @@ object RoundedRectangleShader : Shader("rounded_rect", "rounded_rect") { registerUniform(Uniform.UniformType.VEC2, "halfSize") { halfSize } registerUniform(Uniform.UniformType.VEC2, "centerPos") { centerPos } } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt b/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt new file mode 100644 index 000000000..01f60ac87 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/skillprogress/SkillProgress.kt @@ -0,0 +1,472 @@ +package at.hannibal2.skyhanni.features.skillprogress + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.api.SkillAPI +import at.hannibal2.skyhanni.api.SkillAPI.activeSkill +import at.hannibal2.skyhanni.api.SkillAPI.lastUpdate +import at.hannibal2.skyhanni.api.SkillAPI.oldSkillInfoMap +import at.hannibal2.skyhanni.api.SkillAPI.showDisplay +import at.hannibal2.skyhanni.api.SkillAPI.skillXPInfoMap +import at.hannibal2.skyhanni.config.features.skillprogress.SkillProgressConfig