diff options
author | HiZe <super@hize.be> | 2024-02-24 17:25:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-24 17:25:08 +0100 |
commit | 8dfbcf2a67f0a8207e49d8a97e18c4e80f8fbb96 (patch) | |
tree | 786c4cf47b06f7ac2990e2a62967492d0a5511a5 /src/main/java/at/hannibal2/skyhanni/features/minion | |
parent | bc239065f94548814717e2d07588696ee261c1e3 (diff) | |
download | skyhanni-8dfbcf2a67f0a8207e49d8a97e18c4e80f8fbb96.tar.gz skyhanni-8dfbcf2a67f0a8207e49d8a97e18c4e80f8fbb96.tar.bz2 skyhanni-8dfbcf2a67f0a8207e49d8a97e18c4e80f8fbb96.zip |
Feature: Skill progress display (#957)
Co-authored-by: Thunderblade73 <gaidermarkus@gmail.com>
Co-authored-by: superhize <superhize@gmail.com>
Co-authored-by: Cal <cwolfson58@gmail.com>
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/minion')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/minion/MinionXp.kt | 34 |
1 files changed, 11 insertions, 23 deletions
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<NEUInternalName, XpInfo> = hashMapOf() - data class XpInfo(val type: XpType, val amount: Double) - - private data class MinionStorage(val position: LorenzVec, val xpList: EnumMap<XpType, Double>) { + data class XpInfo(val type: SkillType, val amount: Double) + private data class MinionStorage(val position: LorenzVec, val xpList: EnumMap<SkillType, Double>) { 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<XpType, Double>, + xpTotal: EnumMap<SkillType, Double>, ): Boolean { if (!getHasStorage(minionPosition)) return false val storage = minionStorages.firstOrNull { @@ -101,10 +89,10 @@ class MinionXp { } } - private fun handleItems(inventoryItems: Map<Int, ItemStack>, isMinion: Boolean): EnumMap<XpType, Double> { - val xpTotal = EnumMap<XpType, Double>(XpType::class.java) + private fun handleItems(inventoryItems: Map<Int, ItemStack>, isMinion: Boolean): EnumMap<SkillType, Double> { + val xpTotal = EnumMap<SkillType, Double>(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<MinionXPJson>("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() } } |