aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-12-12 03:50:14 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-12-12 03:50:14 +0100
commit320cda696d0c9046919b714fea37fdc02556080a (patch)
tree0bc5c4f91d75d49a34c7d9a0f708f866ff2b85bc /src/main/java
parent9c3f2a176c085199875c7e32b4e7f6bd5f5485d0 (diff)
downloadskyhanni-320cda696d0c9046919b714fea37fdc02556080a.tar.gz
skyhanni-320cda696d0c9046919b714fea37fdc02556080a.tar.bz2
skyhanni-320cda696d0c9046919b714fea37fdc02556080a.zip
Added Diana Profit Tracker.
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/Storage.java11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/event/diana/DianaConfig.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/event/diana/DianaProfitTrackerConfig.java20
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DianaDrops.java11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaAPI.kt8
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt144
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt7
8 files changed, 203 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index 89061d433..7b32558cc 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -106,6 +106,7 @@ import at.hannibal2.skyhanni.features.dungeon.DungeonTeammateOutlines
import at.hannibal2.skyhanni.features.dungeon.HighlightDungeonDeathmite
import at.hannibal2.skyhanni.features.event.UniqueGiftingOpportunitiesFeatures
import at.hannibal2.skyhanni.features.event.diana.BurrowWarpHelper
+import at.hannibal2.skyhanni.features.event.diana.DianaProfitTracker
import at.hannibal2.skyhanni.features.event.diana.GriffinBurrowHelper
import at.hannibal2.skyhanni.features.event.diana.GriffinBurrowParticleFinder
import at.hannibal2.skyhanni.features.event.diana.GriffinPetWarning
@@ -214,6 +215,7 @@ import at.hannibal2.skyhanni.features.mining.powdertracker.PowderTracker
import at.hannibal2.skyhanni.features.minion.MinionCollectLogic
import at.hannibal2.skyhanni.features.minion.MinionFeatures
import at.hannibal2.skyhanni.features.minion.MinionXp
+import at.hannibal2.skyhanni.features.misc.BetterSignEditing
import at.hannibal2.skyhanni.features.misc.BrewingStandOverlay
import at.hannibal2.skyhanni.features.misc.ButtonOnPause
import at.hannibal2.skyhanni.features.misc.CollectionTracker
@@ -233,7 +235,6 @@ import at.hannibal2.skyhanni.features.misc.MovementSpeedDisplay
import at.hannibal2.skyhanni.features.misc.NonGodPotEffectDisplay
import at.hannibal2.skyhanni.features.misc.ParticleHider
import at.hannibal2.skyhanni.features.misc.PartyMemberOutlines
-import at.hannibal2.skyhanni.features.misc.BetterSignEditing
import at.hannibal2.skyhanni.features.misc.PatcherSendCoordinates
import at.hannibal2.skyhanni.features.misc.PetCandyUsedDisplay
import at.hannibal2.skyhanni.features.misc.PetExpTooltip
@@ -498,6 +499,7 @@ class SkyHanniMod {
loadModule(StatsTuning())
loadModule(NonGodPotEffectDisplay())
loadModule(SoopyGuessBurrow())
+ loadModule(DianaProfitTracker())
loadModule(HighlightJerries())
loadModule(TheGreatSpook())
loadModule(GriffinBurrowHelper)
diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java
index 3bfcdc860..a01c8d7e5 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java
@@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.features.bingo.card.goals.BingoGoal;
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.jerry.frozentreasure.FrozenTreasureTracker;
import at.hannibal2.skyhanni.features.fishing.tracker.FishingProfitTracker;
import at.hannibal2.skyhanni.features.fishing.trophy.TrophyRarity;
@@ -435,5 +436,15 @@ public class Storage {
public FishingProfitTracker.Data fishingProfitTracker = new FishingProfitTracker.Data();
}
+
+ @Expose
+ public DianaStorage diana = new DianaStorage();
+
+ public static class DianaStorage {
+
+ @Expose
+ public DianaProfitTracker.Data dianaProfitTracker = new DianaProfitTracker.Data();
+
+ }
}
}
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 b5d21bade..f7ccf58f6 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
@@ -57,4 +57,9 @@ public class DianaConfig {
@ConfigOption(name = "Always Diana", desc = "Forcefully set the Diana event to be active. This is useful if the auto mayor detection fails.")
@ConfigEditorBoolean
public boolean alwaysDiana = false;
+
+ @Expose
+ @ConfigOption(name = "Diana Profit Tracker", desc = "")
+ @Accordion
+ public DianaProfitTrackerConfig dianaProfitTracker = new DianaProfitTrackerConfig();
}
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/event/diana/DianaProfitTrackerConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/event/diana/DianaProfitTrackerConfig.java
new file mode 100644
index 000000000..2bffc2646
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/event/diana/DianaProfitTrackerConfig.java
@@ -0,0 +1,20 @@
+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;
+
+public class DianaProfitTrackerConfig {
+
+ @Expose
+ @ConfigOption(name = "Enabled", desc = "Count all items you pick up while doing Diana, " +
+ "keep track how often you dug burrows and calculates money per burrow.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean enabled = false;
+
+ @Expose
+ public Position position = new Position(20, 20, false, true);
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DianaDrops.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DianaDrops.java
new file mode 100644
index 000000000..050601c3d
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/DianaDrops.java
@@ -0,0 +1,11 @@
+package at.hannibal2.skyhanni.data.jsonobjects.repo;
+
+import at.hannibal2.skyhanni.utils.NEUInternalName;
+import com.google.gson.annotations.Expose;
+
+import java.util.List;
+
+public class DianaDrops {
+ @Expose
+ public List<NEUInternalName> diana_drops;
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaAPI.kt
index 8c01d0141..972ee4c3a 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaAPI.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaAPI.kt
@@ -5,12 +5,14 @@ import at.hannibal2.skyhanni.data.IslandType
import at.hannibal2.skyhanni.data.MayorElection
import at.hannibal2.skyhanni.data.PetAPI
import at.hannibal2.skyhanni.utils.InventoryUtils
+import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
+import net.minecraft.item.ItemStack
object DianaAPI {
- val spade by lazy { "ANCESTRAL_SPADE".asInternalName() }
+ private val spade by lazy { "ANCESTRAL_SPADE".asInternalName() }
fun hasSpadeInHand() = InventoryUtils.itemInHandId == spade
@@ -20,4 +22,8 @@ object DianaAPI {
fun hasGriffinPet() = PetAPI.currentPet?.contains("Griffin") ?: false
fun featuresEnabled() = IslandType.HUB.isInIsland() && isRitualActive()
+
+ val ItemStack.isDianaSpade get() = getInternalName() == spade
+
+ fun hasSpadeInInventory() = InventoryUtils.getItemsInOwnInventory().any { it.isDianaSpade }
}
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
new file mode 100644
index 000000000..a5d241b90
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/DianaProfitTracker.kt
@@ -0,0 +1,144 @@
+package at.hannibal2.skyhanni.features.event.diana
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.jsonobjects.repo.DianaDrops
+import at.hannibal2.skyhanni.events.GuiRenderEvent
+import at.hannibal2.skyhanni.events.ItemAddEvent
+import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.events.RepositoryReloadEvent
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList
+import at.hannibal2.skyhanni.utils.NEUInternalName
+import at.hannibal2.skyhanni.utils.NumberUtil
+import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber
+import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.StringUtils.matches
+import at.hannibal2.skyhanni.utils.renderables.Renderable
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
+import at.hannibal2.skyhanni.utils.tracker.ItemTrackerData
+import at.hannibal2.skyhanni.utils.tracker.SkyHanniItemTracker
+import com.google.gson.annotations.Expose
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class DianaProfitTracker {
+ private val config get() = SkyHanniMod.feature.event.diana.dianaProfitTracker
+ private var allowedDrops = listOf<NEUInternalName>()
+
+ private val chatDugOutPattern by RepoPattern.pattern(
+ "diana.chat.burrow.dug",
+ "(§eYou dug out a Griffin Burrow!|§eYou finished the Griffin burrow chain!) .*"
+ )
+ private val chatDugOutCoinsPattern by RepoPattern.pattern(
+ "diana.chat.coins",
+ "§6§lWow! §r§eYou dug out §r§6(?<coins>.*) coins§r§e!"
+ )
+
+ private val tracker = SkyHanniItemTracker(
+ "Diana Profit Tracker",
+ { Data() },
+ { it.diana.dianaProfitTracker }) { drawDisplay(it) }
+
+ class Data : ItemTrackerData() {
+ override fun resetItems() {
+ burrowsDug = 0
+ }
+
+ @Expose
+ var burrowsDug: Long = 0
+
+ override fun getDescription(timesDropped: Long): List<String> {
+ val percentage = timesDropped.toDouble() / burrowsDug
+ val perBurrow = LorenzUtils.formatPercentage(percentage.coerceAtMost(1.0))
+
+ return listOf(
+ "§7Dropped §e${timesDropped.addSeparators()} §7times.",
+ "§7Your drop chance per burrow: §c$perBurrow",
+ )
+ }
+
+ override fun getCoinName(item: TrackedItem) = "§6Dug Out Coins"
+
+ override fun getCoinDescription(item: TrackedItem): List<String> {
+ val burrowDugCoinsFormat = NumberUtil.format(item.totalAmount)
+ return listOf(
+ "§7Digging treasures gave you",
+ "§6$burrowDugCoinsFormat coins §7in total."
+ )
+ }
+ }
+
+ private fun drawDisplay(data: Data): List<List<Any>> = buildList {
+ addAsSingletonList("§e§lDiana Profit Tracker")
+
+ val profit = tracker.drawItems(data, { true }, this)
+
+ val treasureCoins = data.burrowsDug
+ addAsSingletonList(
+ Renderable.hoverTips(
+ "§7Burrows dug: §e${treasureCoins.addSeparators()}",
+ listOf("§7You dug out griffin burrows §e${treasureCoins.addSeparators()} §7times.")
+ )
+ )
+
+ val profitFormat = NumberUtil.format(profit)
+ val profitPrefix = if (profit < 0) "§c" else "§6"
+
+ val profitPerBurrow = profit / data.burrowsDug
+ val profitPerBurrowFormat = NumberUtil.format(profitPerBurrow)
+
+ val text = "§eTotal Profit: $profitPrefix$profitFormat coins"
+ addAsSingletonList(
+ Renderable.hoverTips(
+ text,
+ listOf("§7Profit per burrow: $profitPrefix$profitPerBurrowFormat")
+ )
+ )
+
+ tracker.addPriceFromButton(this)
+ }
+
+ @SubscribeEvent
+ fun onItemAdd(event: ItemAddEvent) {
+ if (!isEnabled()) return
+
+ val internalName = event.internalName
+
+ if (!isAllowedItem(internalName)) {
+ LorenzUtils.debug("Ignored non-diana item pickup: '$internalName'")
+ return
+ }
+
+ tracker.addItem(internalName, event.amount)
+ }
+
+ @SubscribeEvent
+ fun onChat(event: LorenzChatEvent) {
+ if (chatDugOutPattern.matches(event.message)) {
+ tracker.modify {
+ it.burrowsDug++
+ }
+ }
+ chatDugOutCoinsPattern.matchMatcher(event.message) {
+ val coins = group("coins").formatNumber().toInt()
+ tracker.addCoins(coins)
+ }
+ }
+
+ @SubscribeEvent
+ fun onRenderOverlay(event: GuiRenderEvent) {
+ if (!isEnabled()) return
+
+ tracker.renderDisplay(config.position)
+ }
+
+ private fun isAllowedItem(internalName: NEUInternalName): Boolean = internalName in allowedDrops
+
+ @SubscribeEvent
+ fun onRepoReload(event: RepositoryReloadEvent) {
+ allowedDrops = event.getConstant<DianaDrops>("DianaDrops").diana_drops
+ }
+
+ fun isEnabled() =
+ LorenzUtils.inSkyBlock && config.enabled && DianaAPI.featuresEnabled() && DianaAPI.hasSpadeInInventory()
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt
index a28358143..5c28738de 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/GriffinBurrowParticleFinder.kt
@@ -7,12 +7,11 @@ import at.hannibal2.skyhanni.events.BurrowDugEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent
import at.hannibal2.skyhanni.events.PacketEvent
+import at.hannibal2.skyhanni.features.event.diana.DianaAPI.isDianaSpade
import at.hannibal2.skyhanni.utils.BlockUtils.getBlockAt
-import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.toLorenzVec
import net.minecraft.init.Blocks
-import net.minecraft.item.ItemStack
import net.minecraft.network.play.server.S2APacketParticles
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -122,15 +121,13 @@ class GriffinBurrowParticleFinder {
if (!config.burrowsSoopyGuess) return
val pos = event.position
- if (event.itemInHand?.isSpade != true || pos.getBlockAt() !== Blocks.grass) return
+ if (event.itemInHand?.isDianaSpade != true || pos.getBlockAt() !== Blocks.grass) return
if (burrows.containsKey(pos)) {
lastDugParticleBurrow = pos
}
}
- private val ItemStack.isSpade get() = getInternalName() == DianaAPI.spade
-
class Burrow(
var location: LorenzVec,
var hasFootstep: Boolean = false,