aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
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.java4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/ArmorDropTracker.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingArmorDrops.kt)92
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/tracker/DisplayMode.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/tracker/SharedTracker.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/tracker/TrackerUtils.kt2
9 files changed, 74 insertions, 46 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index cd2a752d0..ca743ed50 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -139,10 +139,10 @@ import at.hannibal2.skyhanni.features.garden.contest.JacobContestFFNeededDisplay
import at.hannibal2.skyhanni.features.garden.contest.JacobContestStatsSummary
import at.hannibal2.skyhanni.features.garden.contest.JacobContestTimeNeeded
import at.hannibal2.skyhanni.features.garden.contest.JacobFarmingContestsInventory
+import at.hannibal2.skyhanni.features.garden.farming.ArmorDropTracker
import at.hannibal2.skyhanni.features.garden.farming.CropMoneyDisplay
import at.hannibal2.skyhanni.features.garden.farming.CropSpeedMeter
import at.hannibal2.skyhanni.features.garden.farming.DicerDropTracker
-import at.hannibal2.skyhanni.features.garden.farming.FarmingArmorDrops
import at.hannibal2.skyhanni.features.garden.farming.FarmingWeightDisplay
import at.hannibal2.skyhanni.features.garden.farming.GardenBurrowingSporesNotifier
import at.hannibal2.skyhanni.features.garden.farming.GardenCropMilestoneDisplay
@@ -505,7 +505,7 @@ class SkyHanniMod {
loadModule(JacobFarmingContestsInventory())
loadModule(GardenNextJacobContest)
loadModule(WrongFungiCutterWarning())
- loadModule(FarmingArmorDrops())
+ loadModule(ArmorDropTracker)
loadModule(JoinCrystalHollows())
loadModule(CrystalHollowsNamesInCore())
loadModule(GardenVisitorColorNames)
diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java
index 75c9cde83..26fdd365a 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java
@@ -8,8 +8,8 @@ import at.hannibal2.skyhanni.features.event.jerry.frozentreasure.FrozenTreasure;
import at.hannibal2.skyhanni.features.fishing.trophy.TrophyRarity;
import at.hannibal2.skyhanni.features.garden.CropAccessory;
import at.hannibal2.skyhanni.features.garden.CropType;
+import at.hannibal2.skyhanni.features.garden.farming.ArmorDropTracker;
import at.hannibal2.skyhanni.features.garden.farming.DicerDropTracker;
-import at.hannibal2.skyhanni.features.garden.farming.FarmingArmorDrops;
import at.hannibal2.skyhanni.features.garden.fortuneguide.FarmingItems;
import at.hannibal2.skyhanni.features.garden.visitor.VisitorReward;
import at.hannibal2.skyhanni.features.mining.powdertracker.PowderTracker;
@@ -160,7 +160,7 @@ public class Storage {
public long nextSixthVisitorArrival = 0;
@Expose
- public Map<FarmingArmorDrops.ArmorDropType, Integer> farmArmorDrops = new HashMap<>();
+ public ArmorDropTracker.Data armorDropTracker = new ArmorDropTracker.Data();
@Expose
public Map<ComposterUpgrade, Integer> composterUpgrades = 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 3933ed081..c96dbab65 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt
@@ -19,6 +19,7 @@ import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.features.garden.GardenCropTimeCommand
import at.hannibal2.skyhanni.features.garden.GardenNextJacobContest
import at.hannibal2.skyhanni.features.garden.composter.ComposterOverlay
+import at.hannibal2.skyhanni.features.garden.farming.ArmorDropTracker
import at.hannibal2.skyhanni.features.garden.farming.CropMoneyDisplay
import at.hannibal2.skyhanni.features.garden.farming.CropSpeedMeter
import at.hannibal2.skyhanni.features.garden.farming.DicerDropTracker
@@ -168,6 +169,10 @@ object Commands {
"shresetendernodetracker",
"Resets the Ender Node Tracker"
) { EnderNodeTracker.resetCommand(it) }
+ registerCommand(
+ "shresetarmordroptracker",
+ "Resets the Armor Drop Tracker"
+ ) { ArmorDropTracker.resetCommand(it) }
registerCommand("shbingotoggle", "Toggle the bingo card display mode") { BingoCardDisplay.toggleCommand() }
registerCommand(
"shfarmingprofile",
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingArmorDrops.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/ArmorDropTracker.kt
index 2617ad329..0d5bcbf19 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingArmorDrops.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/ArmorDropTracker.kt
@@ -12,23 +12,38 @@ import at.hannibal2.skyhanni.features.garden.CropType
import at.hannibal2.skyhanni.features.garden.GardenAPI
import at.hannibal2.skyhanni.utils.InventoryUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
+import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList
+import at.hannibal2.skyhanni.utils.LorenzUtils.addOrPut
import at.hannibal2.skyhanni.utils.LorenzUtils.sortedDesc
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
-import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import at.hannibal2.skyhanni.utils.jsonobjects.ArmorDropsJson
import at.hannibal2.skyhanni.utils.jsonobjects.ArmorDropsJson.DropInfo
+import at.hannibal2.skyhanni.utils.tracker.SkyHanniTracker
+import at.hannibal2.skyhanni.utils.tracker.TrackerData
+import com.google.gson.JsonObject
+import com.google.gson.annotations.Expose
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import kotlin.time.Duration.Companion.seconds
-class FarmingArmorDrops {
- private var display = emptyList<String>()
- private val storage get() = GardenAPI.storage
+object ArmorDropTracker {
+ private var display = emptyList<List<Any>>()
private var hasArmor = false
private val armorPattern = "(FERMENTO|CROPIE|SQUASH|MELON)_(LEGGINGS|CHESTPLATE|BOOTS|HELMET)".toPattern()
private val config get() = SkyHanniMod.feature.garden.farmingArmorDrop
+ private val tracker = SkyHanniTracker("Armor Drop Tracker", Data(), { it.garden.armorDropTracker }) { update() }
+
+ class Data : TrackerData() {
+ override fun reset() {
+ drops.clear()
+ }
+
+ @Expose
+ var drops: MutableMap<ArmorDropType, Int> = mutableMapOf()
+ }
+
enum class ArmorDropType(val dropName: String, val chatMessage: String) {
CROPIE("§9Cropie", "§6§lRARE CROP! §r§f§r§9Cropie §r§b(Armor Set Bonus)"),
SQUASH("§5Squash", "§6§lRARE CROP! §r§f§r§5Squash §r§b(Armor Set Bonus)"),
@@ -54,9 +69,9 @@ class FarmingArmorDrops {
}
private fun addDrop(drop: ArmorDropType) {
- val drops = storage?.farmArmorDrops ?: return
- val old = drops[drop] ?: 0
- drops[drop] = old + 1
+ tracker.modify {
+ it.drops.addOrPut(drop, 1)
+ }
update()
}
@@ -64,14 +79,17 @@ class FarmingArmorDrops {
display = drawDisplay()
}
- private fun drawDisplay() = buildList {
- val drops = storage?.farmArmorDrops ?: return@buildList
+ private fun drawDisplay() = buildList<List<Any>> {
+ val drops = tracker.currentDisplay()?.drops ?: return@buildList
- add("§7RNG Drops for Farming Armor:")
+ addAsSingletonList("§7RNG Drops for Farming Armor:")
+ tracker.addDisplayModeToggle(this)
for ((drop, amount) in drops.sortedDesc()) {
val dropName = drop.dropName
- add(" §7- §e${amount.addSeparators()}x $dropName")
+ addAsSingletonList(" §7- §e${amount.addSeparators()}x $dropName")
}
+
+ tracker.addSessionResetButton(this)
}
@SubscribeEvent
@@ -80,12 +98,12 @@ class FarmingArmorDrops {
}
@SubscribeEvent
- fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) {
+ fun onRenderOverlay(event: GuiRenderEvent) {
if (!GardenAPI.inGarden()) return
if (!config.enabled) return
if (!hasArmor) return
- config.pos.renderStrings(display, posLabel = "Farming Armor Drops")
+ tracker.renderDisplay(config.pos, display)
}
@SubscribeEvent
@@ -111,32 +129,30 @@ class FarmingArmorDrops {
armorDropInfo = data.special_crops
}
- companion object {
- var armorDropInfo = mapOf<String, DropInfo>()
- private var currentArmorDropChance = 0.0
- private var lastCalculationTime = SimpleTimeMark.farPast()
+ private var armorDropInfo = mapOf<String, DropInfo>()
+ private var currentArmorDropChance = 0.0
+ private var lastCalculationTime = SimpleTimeMark.farPast()
- fun getDropsPerHour(crop: CropType?): Double {
- if (crop == null) return 0.0
+ fun getDropsPerHour(crop: CropType?): Double {
+ if (crop == null) return 0.0
- if (lastCalculationTime.passedSince() > 5.seconds) {
- lastCalculationTime = SimpleTimeMark.now()
+ if (lastCalculationTime.passedSince() > 5.seconds) {
+ lastCalculationTime = SimpleTimeMark.now()
- val armorDropName = crop.specialDropType
- val armorName = armorDropInfo[armorDropName]?.armor_type ?: return 0.0
- val pieceCount = InventoryUtils.getArmor()
- .mapNotNull { it?.getInternalName()?.asString() }
- .count { it.contains(armorName) || it.contains("FERMENTO") }
+ val armorDropName = crop.specialDropType
+ val armorName = armorDropInfo[armorDropName]?.armor_type ?: return 0.0
+ val pieceCount = InventoryUtils.getArmor()
+ .mapNotNull { it?.getInternalName()?.asString() }
+ .count { it.contains(armorName) || it.contains("FERMENTO") }
- val dropRates = armorDropInfo[armorDropName]?.chance ?: return 0.0
- var dropRate = 0.0
- if (pieceCount > 0 && dropRates.size >= pieceCount) {
- dropRate = dropRates[pieceCount - 1]
- }
- currentArmorDropChance = (dropRate * 60 * 60.0) / 100
+ val dropRates = armorDropInfo[armorDropName]?.chance ?: return 0.0
+ var dropRate = 0.0
+ if (pieceCount > 0 && dropRates.size >= pieceCount) {
+ dropRate = dropRates[pieceCount - 1]
}
- return currentArmorDropChance
+ currentArmorDropChance = (dropRate * 60 * 60.0) / 100
}
+ return currentArmorDropChance
}
@SubscribeEvent
@@ -144,5 +160,15 @@ class FarmingArmorDrops {
event.move(3, "garden.farmingArmorDropsEnabled", "garden.farmingArmorDrop.enabled")
event.move(3, "garden.farmingArmorDropsHideChat", "garden.farmingArmorDrop.hideChat")
event.move(3, "garden.farmingArmorDropsPos", "garden.farmingArmorDrop.pos")
+
+ event.move(8, "#profile.garden.farmArmorDrops", "#profile.garden.armorDropTracker") { old ->
+ val new = JsonObject()
+ new.add("drops", old)
+ new
+ }
+ }
+
+ fun resetCommand(args: Array<String>) {
+ tracker.resetCommand(args, "shresetarmordroptracker")
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt
index 0cc07f7e7..91abf10a4 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt
@@ -155,7 +155,7 @@ object CropMoneyDisplay {
if (config.armor) {
val amountPerHour =
- it.multiplier * GardenCropSpeed.getRecentBPS() * FarmingArmorDrops.getDropsPerHour(it)
+ it.multiplier * GardenCropSpeed.getRecentBPS() * ArmorDropTracker.getDropsPerHour(it)
extraArmorCoins = amountPerHour * it.specialDropType.asInternalName().getNpcPrice()
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/tracker/DisplayMode.kt b/src/main/java/at/hannibal2/skyhanni/utils/tracker/DisplayMode.kt
index 6c0e14439..55441953c 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/DisplayMode.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/DisplayMode.kt
@@ -2,6 +2,6 @@ package at.hannibal2.skyhanni.utils.tracker
enum class DisplayMode(val displayName: String) {
TOTAL("Total"),
- CURRENT("This Session"),
+ SESSION("This Session"),
;
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SharedTracker.kt b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SharedTracker.kt
index 341600467..9b5ae1d90 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SharedTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SharedTracker.kt
@@ -11,8 +11,6 @@ class SharedTracker<T : TrackerData>(
fun get(displayMode: DisplayMode) = when (displayMode) {
DisplayMode.TOTAL -> total
- DisplayMode.CURRENT -> currentSession
+ DisplayMode.SESSION -> currentSession
}
-
- fun getCurrent() = get(TrackerUtils.currentDisplayMode)
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt
index 6ff8febc7..e1b4c42ad 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt
@@ -26,7 +26,7 @@ class SkyHanniTracker<Data : TrackerData>(
}
fun addSessionResetButton(list: MutableList<List<Any>>) {
- if (inventoryOpen && TrackerUtils.currentDisplayMode == DisplayMode.CURRENT) {
+ if (inventoryOpen && TrackerUtils.currentDisplayMode == DisplayMode.SESSION) {
list.addSessionResetButton(name, getSharedTracker()) {
update()
}
@@ -45,8 +45,7 @@ class SkyHanniTracker<Data : TrackerData>(
}
}
- // rename
- fun currentDisplay() = getSharedTracker()?.getCurrent()
+ fun currentDisplay() = getSharedTracker()?.get(TrackerUtils.currentDisplayMode)
fun resetCommand(args: Array<String>, command: String) {
TrackerUtils.resetCommand(name, command, args, getSharedTracker()) {
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/tracker/TrackerUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/tracker/TrackerUtils.kt
index cc2dab37f..ec527c9e5 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/TrackerUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/TrackerUtils.kt
@@ -30,7 +30,7 @@ object TrackerUtils {
"§c$name"
),
) {
- data?.get(DisplayMode.CURRENT)?.let {
+ data?.get(DisplayMode.SESSION)?.let {
reset(it) {
update()
}