diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-12-16 16:32:07 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-12-16 16:32:07 +0100 |
commit | 5d027819967ad664dd6b79f2e3c90c752df55e84 (patch) | |
tree | 1542a67f137999c57ca1daa08b0c237b96e0c9d7 /src/main/java | |
parent | 6a9599fa9820b3efe0e5fdbb1d546ad8a0aa4de7 (diff) | |
download | skyhanni-5d027819967ad664dd6b79f2e3c90c752df55e84.tar.gz skyhanni-5d027819967ad664dd6b79f2e3c90c752df55e84.tar.bz2 skyhanni-5d027819967ad664dd6b79f2e3c90c752df55e84.zip |
Added Mythological Mob Tracker.
Diffstat (limited to 'src/main/java')
6 files changed, 159 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java index e17646663..7f4d6c183 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java @@ -6,6 +6,7 @@ import at.hannibal2.skyhanni.features.combat.endernodetracker.EnderNodeTracker; import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostData; import at.hannibal2.skyhanni.features.dungeon.DungeonAPI; import at.hannibal2.skyhanni.features.event.diana.DianaProfitTracker; +import at.hannibal2.skyhanni.features.event.diana.MythologicalMobTracker; import at.hannibal2.skyhanni.features.event.jerry.frozentreasure.FrozenTreasureTracker; import at.hannibal2.skyhanni.features.fishing.tracker.FishingProfitTracker; import at.hannibal2.skyhanni.features.fishing.trophy.TrophyRarity; @@ -450,8 +451,12 @@ public class Storage { public static class DianaStorage { @Expose + // TODO rename to 'profitTracker' public DianaProfitTracker.Data dianaProfitTracker = new DianaProfitTracker.Data(); + @Expose + public MythologicalMobTracker.Data mythologicalMobTracker = new MythologicalMobTracker.Data(); + } } } 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 8f4d96483..f169a04f8 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -15,7 +15,9 @@ 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.event.diana.BurrowWarpHelper +import at.hannibal2.skyhanni.features.event.diana.DianaProfitTracker import at.hannibal2.skyhanni.features.event.diana.InquisitorWaypointShare +import at.hannibal2.skyhanni.features.event.diana.MythologicalMobTracker import at.hannibal2.skyhanni.features.event.jerry.frozentreasure.FrozenTreasureTracker import at.hannibal2.skyhanni.features.fame.AccountUpgradeReminder import at.hannibal2.skyhanni.features.fame.CityProjectFeatures @@ -208,6 +210,14 @@ object Commands { "shresetvermintracker", "Resets the Vermin Tracker" ) { VerminTracker.resetCommand(it) } + registerCommand( + "shresetdianaprofittracker", + "Resets the Diana Profit Tracker" + ) { DianaProfitTracker.resetCommand(it) } + registerCommand( + "shresetmythologicalmobtracker", + "Resets the Mythological Mob Tracker" + ) { MythologicalMobTracker.resetCommand(it) } } private fun usersBugFix() { diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/event/diana/DianaConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/event/diana/DianaConfig.java index a99268b0a..9db30db0c 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/event/diana/DianaConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/event/diana/DianaConfig.java @@ -68,4 +68,9 @@ public class DianaConfig { @ConfigOption(name = "Diana Profit Tracker", desc = "") @Accordion public DianaProfitTrackerConfig dianaProfitTracker = new DianaProfitTrackerConfig(); + + @Expose + @ConfigOption(name = "Mythological Mob Tracker", desc = "") + @Accordion + public MythologicalMobTrackerConfig mythologicalMobtracker = new MythologicalMobTrackerConfig(); } diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/event/diana/MythologicalMobTrackerConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/event/diana/MythologicalMobTrackerConfig.java new file mode 100644 index 000000000..2dac93553 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/event/diana/MythologicalMobTrackerConfig.java @@ -0,0 +1,30 @@ +package at.hannibal2.skyhanni.config.features.event.diana; + +import at.hannibal2.skyhanni.config.FeatureToggle; +import at.hannibal2.skyhanni.config.core.config.Position; +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 MythologicalMobTrackerConfig { + + @Expose + @ConfigOption(name = "Enabled", desc = "Counts the different mythological mobs you have dug up.") + @ConfigEditorBoolean + @FeatureToggle + public boolean enabled = false; + + @Expose + public Position position = new Position(20, 20, false, true); + + @Expose + @ConfigOption(name = "Show Percentage", desc = "Show percentage of mob compared to all mobs") + @ConfigEditorBoolean + public Property<Boolean> showPercentage = Property.of(false); + + @Expose + @ConfigOption(name = "Hide Chat", desc = "Hide the chat messages when digging up a mythological mob.") + @ConfigEditorBoolean + public boolean hideChat = false; +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt index b65f4e510..d6849e9aa 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt @@ -21,7 +21,7 @@ import at.hannibal2.skyhanni.utils.tracker.SkyHanniItemTracker import com.google.gson.annotations.Expose import net.minecraftforge.fml.common.eventhandler.SubscribeEvent -class DianaProfitTracker { +object DianaProfitTracker { private val config get() = SkyHanniMod.feature.event.diana.dianaProfitTracker private var allowedDrops = listOf<NEUInternalName>() @@ -139,5 +139,9 @@ class DianaProfitTracker { allowedDrops = event.getConstant<DianaDrops>("DianaDrops").diana_drops } + fun resetCommand(args: Array<String>) { + tracker.resetCommand(args, "shresetdianaprofittracker") + } + private fun isEnabled() = DianaAPI.isDoingDiana() && config.enabled } diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/MythologicalMobTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/MythologicalMobTracker.kt new file mode 100644 index 000000000..dfb0de36a --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/MythologicalMobTracker.kt @@ -0,0 +1,104 @@ +package at.hannibal2.skyhanni.features.event.diana + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.ConfigLoadEvent +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList +import at.hannibal2.skyhanni.utils.LorenzUtils.addOrPut +import at.hannibal2.skyhanni.utils.LorenzUtils.sumAllValues +import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators +import at.hannibal2.skyhanni.utils.StringUtils.matches +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import at.hannibal2.skyhanni.utils.tracker.SkyHanniTracker +import at.hannibal2.skyhanni.utils.tracker.TrackerData +import com.google.gson.annotations.Expose +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.util.regex.Pattern + +object MythologicalMobTracker { + + private val group = RepoPattern.group("event.diana.mythological.tracker") + + private val minotaurPattern by group.pattern("minotaur", ".* §r§eYou dug out a §r§2Minotaur§r§e!") + private val gaiaConstructPattern by group.pattern("gaiaconstruct", ".* §r§eYou dug out a §r§2Gaia Construct§r§e!") + private val minosChampionPattern by group.pattern("minoschampion", ".* §r§eYou dug out a §r§2Minos Champion§r§e!") + private val siameseLynxesPattern by group.pattern("siameselynxes", ".* §r§eYou dug out §r§2Siamese Lynxes§r§e!") + private val minosHunterPattern by group.pattern("minoshunter", ".* §r§eYou dug out a §r§2Minos Hunter§r§e!") + private val minosInquisitorPattern by group.pattern( + "minosinquisitor", + ".* §r§eYou dug out a §r§2Minos Inquisitor§r§e!" + ) + + private val config get() = SkyHanniMod.feature.event.diana.mythologicalMobtracker + + private val tracker = SkyHanniTracker("Mythological Mob Tracker", { Data() }, { it.diana.mythologicalMobTracker }) + { drawDisplay(it) } + + class Data : TrackerData() { + override fun reset() { + count.clear() + } + + @Expose + var count: MutableMap<MythologicalMobType, Int> = mutableMapOf() + } + + enum class MythologicalMobType(val displayName: String, val pattern: Pattern) { + MINOTAUR("§2Minotaur", minotaurPattern), + GAIA_CONSTRUCT("§2Gaia Construct", gaiaConstructPattern), + MINOS_CHAMPION("§2Minos Champion", minosChampionPattern), + SIAMESE_LYNXES("§2Siamese Lynxes", siameseLynxesPattern), + MINOS_HUNTER("§2Minos Hunter", minosHunterPattern), + MINOS_INQUISITOR("§cMinos Inquisitor", minosInquisitorPattern), + } + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + MythologicalMobType.entries.forEach { mobType -> + if (mobType.pattern.matches(event.message)) { + tracker.modify { it.count.addOrPut(mobType, 1) } + + if (config.hideChat) { + event.blockedReason = "mythological_mob_dug" + } + } + } + } + + private fun drawDisplay(data: Data): List<List<Any>> = buildList { + addAsSingletonList("§7Mythological Mob Tracker:") + val total = data.count.sumAllValues() + data.count.entries.sortedByDescending { it.value }.forEach { (mobType, amount) -> + + val percentageSuffix = if (config.showPercentage.get()) { + val percentage = LorenzUtils.formatPercentage(amount.toDouble() / total) + " §7$percentage" + } else "" + + addAsSingletonList(" §7- §e${amount.addSeparators()} ${mobType.displayName}$percentageSuffix") + } + addAsSingletonList(" §7- §e${total.addSeparators()} §bTotal Mobs") + } + + @SubscribeEvent + fun onConfigLoad(event: ConfigLoadEvent) { + LorenzUtils.onToggle(config.showPercentage) { + tracker.update() + } + } + + @SubscribeEvent + fun onRenderOverlay(event: GuiRenderEvent) { + if (!isEnabled()) return + + tracker.renderDisplay(config.position) + } + + fun resetCommand(args: Array<String>) { + tracker.resetCommand(args, "shresetmythologicalmobtracker") + } + + private fun isEnabled() = DianaAPI.isDoingDiana() && config.enabled +} |