From 50f781c88ddffb98466ba5a5fcca7b770ef2490d Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sun, 24 Dec 2023 14:31:06 +0100 Subject: Default disabled and renamed some garden features. --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 4 +- .../java/at/hannibal2/skyhanni/config/Storage.java | 4 +- .../hannibal2/skyhanni/config/commands/Commands.kt | 4 +- .../features/garden/ArmorDropTrackerConfig.java | 24 ++++ .../config/features/garden/DicerCounterConfig.java | 24 ---- .../features/garden/DicerRngDropTrackerConfig.java | 24 ++++ .../features/garden/FarmingArmorDropsConfig.java | 24 ---- .../features/garden/FarmingFortuneConfig.java | 2 +- .../config/features/garden/GardenConfig.java | 11 +- .../config/features/garden/GardenLevelConfig.java | 2 +- .../config/features/garden/MoneyPerHourConfig.java | 2 +- .../features/garden/composter/ComposterConfig.java | 2 +- .../features/garden/cropmilestones/NextConfig.java | 2 +- .../garden/optimalspeed/OptimalSpeedConfig.java | 2 +- .../features/garden/farming/DicerDropTracker.kt | 158 --------------------- .../features/garden/farming/DicerRngDropTracker.kt | 158 +++++++++++++++++++++ 16 files changed, 224 insertions(+), 223 deletions(-) create mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/garden/ArmorDropTrackerConfig.java delete mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/garden/DicerCounterConfig.java create mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/garden/DicerRngDropTrackerConfig.java delete mode 100644 src/main/java/at/hannibal2/skyhanni/config/features/garden/FarmingArmorDropsConfig.java delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerDropTracker.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropTracker.kt (limited to 'src') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 3d5bff605..079565b39 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -167,7 +167,7 @@ import at.hannibal2.skyhanni.features.garden.contest.JacobFarmingContestsInvento 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.DicerRngDropTracker import at.hannibal2.skyhanni.features.garden.farming.FarmingWeightDisplay import at.hannibal2.skyhanni.features.garden.farming.GardenBurrowingSporesNotifier import at.hannibal2.skyhanni.features.garden.farming.GardenCropMilestoneDisplay @@ -550,7 +550,7 @@ class SkyHanniMod { loadModule(GardenDeskInSBMenu()) loadModule(GardenLevelDisplay()) loadModule(FarmingWeightDisplay()) - loadModule(DicerDropTracker) + loadModule(DicerRngDropTracker) loadModule(CropMoneyDisplay) loadModule(JacobFarmingContestsInventory()) loadModule(GardenNextJacobContest) diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java index d18fe3546..07641b44c 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java @@ -14,7 +14,7 @@ import at.hannibal2.skyhanni.features.garden.CropAccessory; import at.hannibal2.skyhanni.features.garden.CropType; import at.hannibal2.skyhanni.features.garden.GardenPlotAPI; import at.hannibal2.skyhanni.features.garden.farming.ArmorDropTracker; -import at.hannibal2.skyhanni.features.garden.farming.DicerDropTracker; +import at.hannibal2.skyhanni.features.garden.farming.DicerRngDropTracker; import at.hannibal2.skyhanni.features.garden.fortuneguide.FarmingItems; import at.hannibal2.skyhanni.features.garden.visitor.VisitorReward; import at.hannibal2.skyhanni.features.mining.powdertracker.PowderTracker; @@ -182,7 +182,7 @@ public class Storage { public CropAccessory savedCropAccessory = null; @Expose - public DicerDropTracker.Data dicerDropTracker = new DicerDropTracker.Data(); + public DicerRngDropTracker.Data dicerDropTracker = new DicerRngDropTracker.Data(); @Expose public long informedAboutLowMatter = 0; 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 a8bf4bb20..da54eb54e 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -29,7 +29,7 @@ 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 +import at.hannibal2.skyhanni.features.garden.farming.DicerRngDropTracker import at.hannibal2.skyhanni.features.garden.farming.FarmingWeightDisplay import at.hannibal2.skyhanni.features.garden.farming.GardenStartLocation import at.hannibal2.skyhanni.features.garden.fortuneguide.CaptureFarmingGear @@ -173,7 +173,7 @@ object Commands { ) { clearFarmingItems() } registerCommand("shresetghostcounter", "Resets the ghost counter") { GhostUtil.reset() } registerCommand("shresetpowdertracker", "Resets the Powder Tracker") { PowderTracker.resetCommand(it) } - registerCommand("shresetdicertracker", "Resets the Dicer Drop Tracker") { DicerDropTracker.resetCommand(it) } + registerCommand("shresetdicertracker", "Resets the Dicer Drop Tracker") { DicerRngDropTracker.resetCommand(it) } registerCommand( "shresetendernodetracker", "Resets the Ender Node Tracker" diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/ArmorDropTrackerConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/ArmorDropTrackerConfig.java new file mode 100644 index 000000000..f1b488b26 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/ArmorDropTrackerConfig.java @@ -0,0 +1,24 @@ +package at.hannibal2.skyhanni.config.features.garden; + +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 ArmorDropTrackerConfig { + @Expose + @ConfigOption(name = "Enabled", desc = "Track all §9Cropie§7, §5Squash §7and §6Fermento §7dropped.") + @ConfigEditorBoolean + @FeatureToggle + public boolean enabled = false; + + @Expose + @ConfigOption(name = "Hide Chat", desc = "Hide the chat message when receiving a farming armor drop.") + @ConfigEditorBoolean + @FeatureToggle + public boolean hideChat = false; + + @Expose + public Position pos = new Position(16, -232, false, true); +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/DicerCounterConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/DicerCounterConfig.java deleted file mode 100644 index 63087dab1..000000000 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/DicerCounterConfig.java +++ /dev/null @@ -1,24 +0,0 @@ -package at.hannibal2.skyhanni.config.features.garden; - -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 DicerCounterConfig { - @Expose - @ConfigOption(name = "RNG Drop Counter", desc = "Count RNG drops for Melon Dicer and Pumpkin Dicer.") - @ConfigEditorBoolean - @FeatureToggle - public boolean display = true; - - @Expose - @ConfigOption(name = "Hide Chat", desc = "Hide the chat message when dropping a RNG Dicer drop.") - @ConfigEditorBoolean - @FeatureToggle - public boolean hideChat = false; - - @Expose - public Position pos = new Position(16, -232, false, true); -} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/DicerRngDropTrackerConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/DicerRngDropTrackerConfig.java new file mode 100644 index 000000000..fb7614375 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/DicerRngDropTrackerConfig.java @@ -0,0 +1,24 @@ +package at.hannibal2.skyhanni.config.features.garden; + +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 DicerRngDropTrackerConfig { + @Expose + @ConfigOption(name = "Enable Tracker", desc = "Track RNG drops for Melon Dicer and Pumpkin Dicer.") + @ConfigEditorBoolean + @FeatureToggle + public boolean display = true; + + @Expose + @ConfigOption(name = "Hide Chat", desc = "Hide the chat message when dropping a RNG Dicer drop.") + @ConfigEditorBoolean + @FeatureToggle + public boolean hideChat = false; + + @Expose + public Position pos = new Position(16, -232, false, true); +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/FarmingArmorDropsConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/FarmingArmorDropsConfig.java deleted file mode 100644 index 64d04f932..000000000 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/FarmingArmorDropsConfig.java +++ /dev/null @@ -1,24 +0,0 @@ -package at.hannibal2.skyhanni.config.features.garden; - -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 FarmingArmorDropsConfig { - @Expose - @ConfigOption(name = "Show Counter", desc = "Count all §9Cropie§7, §5Squash §7and §6Fermento §7dropped.") - @ConfigEditorBoolean - @FeatureToggle - public boolean enabled = true; - - @Expose - @ConfigOption(name = "Hide Chat", desc = "Hide the chat message when receiving a farming armor drop.") - @ConfigEditorBoolean - @FeatureToggle - public boolean hideChat = false; - - @Expose - public Position pos = new Position(16, -232, false, true); -} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/FarmingFortuneConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/FarmingFortuneConfig.java index ff5f6c62d..73c32a0fa 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/FarmingFortuneConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/FarmingFortuneConfig.java @@ -16,7 +16,7 @@ public class FarmingFortuneConfig { ) @ConfigEditorBoolean @FeatureToggle - public boolean display = true; + public boolean display = false; @ConfigOption(name = "Farming Fortune Guide", desc = "Opens a guide that breaks down your Farming Fortune.\n§eCommand: /ff") @ConfigEditorButton(buttonText = "Open") diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenConfig.java index 77e497b5e..b541cd0ee 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenConfig.java @@ -55,9 +55,10 @@ public class GardenConfig { public EliteFarmingWeightConfig eliteFarmingWeights = new EliteFarmingWeightConfig(); @Expose - @ConfigOption(name = "Dicer Counter", desc = "") + @ConfigOption(name = "Dicer RNG Drop Tracker", desc = "") @Accordion - public DicerCounterConfig dicerCounters = new DicerCounterConfig(); + // TODO rename to dicerRngDropTracker + public DicerRngDropTrackerConfig dicerCounters = new DicerRngDropTrackerConfig(); @Expose @ConfigOption(name = "Money per Hour", desc = "") @@ -70,10 +71,10 @@ public class GardenConfig { public NextJacobContestConfig nextJacobContests = new NextJacobContestConfig(); @Expose - @ConfigOption(name = "Farming Armor Drops", desc = "") - + @ConfigOption(name = "Armor Drop Tracker", desc = "") @Accordion - public FarmingArmorDropsConfig farmingArmorDrop = new FarmingArmorDropsConfig(); + // TODO renmae to armorDropTracker + public ArmorDropTrackerConfig farmingArmorDrop = new ArmorDropTrackerConfig(); @Expose @ConfigOption(name = "Anita Shop", desc = "") diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenLevelConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenLevelConfig.java index 07f330dcd..cbb3bbe7f 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenLevelConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/GardenLevelConfig.java @@ -11,7 +11,7 @@ public class GardenLevelConfig { @ConfigOption(name = "Display", desc = "Show the current Garden level and progress to the next level.") @ConfigEditorBoolean @FeatureToggle - public boolean display = true; + public boolean display = false; @Expose public Position pos = new Position(390, 40, false, true); diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/MoneyPerHourConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/MoneyPerHourConfig.java index 77c9eddc2..5bea2c4ba 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/MoneyPerHourConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/MoneyPerHourConfig.java @@ -24,7 +24,7 @@ public class MoneyPerHourConfig { "Supports Bountiful, Mushroom Cow Perk, Armor Crops and Dicer Drops. Their toggles are below.") @ConfigEditorBoolean @FeatureToggle - public boolean display = true; + public boolean display = false; // TODO moulconfig runnable support @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/composter/ComposterConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/composter/ComposterConfig.java index ab8d1a703..a2be38643 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/composter/ComposterConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/composter/ComposterConfig.java @@ -98,7 +98,7 @@ public class ComposterConfig { ) @ConfigEditorBoolean @FeatureToggle - public boolean displayEnabled = true; + public boolean displayEnabled = false; @Expose @ConfigOption( diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/cropmilestones/NextConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/cropmilestones/NextConfig.java index 1145ca7d5..d1609e322 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/cropmilestones/NextConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/cropmilestones/NextConfig.java @@ -17,7 +17,7 @@ public class NextConfig { desc = "Lists all crops and their ETA till next milestone. Sorts for best crop for getting garden or SkyBlock levels.") @ConfigEditorBoolean @FeatureToggle - public boolean bestDisplay = true; + public boolean bestDisplay = false; // TODO moulconfig runnable support @Expose diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/optimalspeed/OptimalSpeedConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/optimalspeed/OptimalSpeedConfig.java index 672f1f21e..4b3a18b6e 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/optimalspeed/OptimalSpeedConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/optimalspeed/OptimalSpeedConfig.java @@ -13,7 +13,7 @@ public class OptimalSpeedConfig { "(Thanks MelonKingDE for the default values).") @ConfigEditorBoolean @FeatureToggle - public boolean showOnHUD = true; + public boolean showOnHUD = false; @Expose @ConfigOption(name = "Warning Title", desc = "Warn via title when you don't have the optimal speed.") diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerDropTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerDropTracker.kt deleted file mode 100644 index b347d6dfe..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerDropTracker.kt +++ /dev/null @@ -1,158 +0,0 @@ -package at.hannibal2.skyhanni.features.garden.farming - -import at.hannibal2.skyhanni.config.ConfigManager -import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator -import at.hannibal2.skyhanni.events.GardenToolChangeEvent -import at.hannibal2.skyhanni.events.GuiRenderEvent -import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.features.garden.CropType -import at.hannibal2.skyhanni.features.garden.GardenAPI -import at.hannibal2.skyhanni.utils.ItemUtils.name -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.StringUtils.matchMatcher -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 DicerDropTracker { - private val itemDrops = mutableListOf() - private val config get() = GardenAPI.config.dicerCounters - private val tracker = SkyHanniTracker("Dicer Drop Tracker", { Data() }, { it.garden.dicerDropTracker }) - { drawDisplay(it) } - - class Data : TrackerData() { - override fun reset() { - drops.clear() - } - - @Expose - var drops: MutableMap> = mutableMapOf() - } - - // TODO USE SH-REPO - private val melonUncommonDropPattern = - "§a§lUNCOMMON DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Melon§r§e!".toPattern() - private val melonRareDropPattern = - "§9§lRARE DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Melon§r§e!".toPattern() - private val melonCrazyRareDropPattern = - "§d§lCRAZY RARE DROP! §r§eDicer dropped §r§[a|9](\\d+)x §r§[a|9]Enchanted Melon(?: Block)?§r§e!".toPattern() - private val melonRngesusDropPattern = - "§5§lPRAY TO RNGESUS DROP! §r§eDicer dropped §r§9(\\d+)x §r§9Enchanted Melon Block§r§e!".toPattern() - - private val pumpkinUncommonDropPattern = - "§a§lUNCOMMON DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Pumpkin§r§e!".toPattern() - private val pumpkinRareDropPattern = - "§9§lRARE DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Pumpkin§r§e!".toPattern() - private val pumpkinCrazyRareDropPattern = - "§d§lCRAZY RARE DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Pumpkin§r§e!".toPattern() - private val pumpkinRngesusDropPattern = - "§5§lPRAY TO RNGESUS DROP! §r§eDicer dropped §r§[a|9](\\d+)x §r§(aEnchanted|9Polished) Pumpkin§r§e!".toPattern() - - init { - itemDrops.add(ItemDrop(CropType.MELON, DropRarity.UNCOMMON, melonUncommonDropPattern)) - itemDrops.add(ItemDrop(CropType.MELON, DropRarity.RARE, melonRareDropPattern)) - itemDrops.add(ItemDrop(CropType.MELON, DropRarity.CRAZY_RARE, melonCrazyRareDropPattern)) - itemDrops.add(ItemDrop(CropType.MELON, DropRarity.PRAY_TO_RNGESUS, melonRngesusDropPattern)) - - itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.UNCOMMON, pumpkinUncommonDropPattern)) - itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.RARE, pumpkinRareDropPattern)) - itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.CRAZY_RARE, pumpkinCrazyRareDropPattern)) - itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.PRAY_TO_RNGESUS, pumpkinRngesusDropPattern)) - } - - enum class DropRarity(val displayName: String) { - UNCOMMON("§a§lUNCOMMON DROP"), - RARE("§9§lRARE DROP"), - CRAZY_RARE("§d§lCRAZY RARE DROP"), - PRAY_TO_RNGESUS("§5§lPRAY TO RNGESUS DROP"), - } - - @SubscribeEvent - fun onChat(event: LorenzChatEvent) { - if (!GardenAPI.inGarden()) return - if (!config.hideChat && !config.display) return - - val message = event.message - for (drop in itemDrops) { - drop.pattern.matchMatcher(message) { - addDrop(drop.crop, drop.rarity) - if (config.hideChat) { - event.blockedReason = "dicer_drop_tracker" - } - return - } - } - } - - private fun drawDisplay(storage: Data) = buildList> { - val cropInHand = cropInHand ?: return@buildList - val items = storage.drops.getOrPut(cropInHand) { mutableMapOf() } - addAsSingletonList("§7Dicer Drop Tracker for $toolName§7:") - for ((rarity, amount) in items.sortedDesc()) { - val displayName = rarity.displayName - addAsSingletonList(" §7- §e${amount.addSeparators()}x $displayName") - } - - } - - private var cropInHand: CropType? = null - private var toolName = "" - - @SubscribeEvent - fun onGardenToolChange(event: GardenToolChangeEvent) { - val crop = event.crop - cropInHand = if (crop == CropType.MELON || crop == CropType.PUMPKIN) crop else null - if (cropInHand != null) { - toolName = event.toolItem!!.name!! - } - tracker.update() - } - - private fun addDrop(crop: CropType, rarity: DropRarity) { - tracker.modify { - val map = it.drops.getOrPut(crop) { mutableMapOf() } - map.addOrPut(rarity, 1) - } - } - - @SubscribeEvent - fun onRenderOverlay(event: GuiRenderEvent) { - if (!isEnabled()) return - - tracker.renderDisplay(config.pos) - } - - class ItemDrop(val crop: CropType, val rarity: DropRarity, val pattern: Pattern) - - fun isEnabled() = GardenAPI.inGarden() && config.display - - @SubscribeEvent - fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { - event.move(3, "garden.dicerCounterDisplay", "garden.dicerCounters.display") - event.move(3, "garden.dicerCounterHideChat", "garden.dicerCounters.hideChat") - event.move(3, "garden.dicerCounterPos", "garden.dicerCounters.pos") - - event.move(7, "#profile.garden.dicerRngDrops", "#profile.garden.dicerDropTracker.drops") { old -> - val items: MutableMap> = mutableMapOf() - val oldItems = ConfigManager.gson.fromJson>(old, Map::class.java) - for ((internalName, amount) in oldItems) { - val split = internalName.split(".") - val crop = CropType.getByName(split[0]) - val rarityName = split[1] - val rarity = DropRarity.valueOf(rarityName) - items.getOrPut(crop) { mutableMapOf() }[rarity] = amount - } - - ConfigManager.gson.toJsonTree(items) - } - } - - fun resetCommand(args: Array) { - tracker.resetCommand(args, "shresetdicertracker") - } -} diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropTracker.kt new file mode 100644 index 000000000..bc6db268c --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropTracker.kt @@ -0,0 +1,158 @@ +package at.hannibal2.skyhanni.features.garden.farming + +import at.hannibal2.skyhanni.config.ConfigManager +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.events.GardenToolChangeEvent +import at.hannibal2.skyhanni.events.GuiRenderEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.features.garden.CropType +import at.hannibal2.skyhanni.features.garden.GardenAPI +import at.hannibal2.skyhanni.utils.ItemUtils.name +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.StringUtils.matchMatcher +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 DicerRngDropTracker { + private val itemDrops = mutableListOf() + private val config get() = GardenAPI.config.dicerCounters + private val tracker = SkyHanniTracker("Dicer Rng Drop Tracker", { Data() }, { it.garden.dicerDropTracker }) + { drawDisplay(it) } + + class Data : TrackerData() { + override fun reset() { + drops.clear() + } + + @Expose + var drops: MutableMap> = mutableMapOf() + } + + // TODO USE SH-REPO + private val melonUncommonDropPattern = + "§a§lUNCOMMON DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Melon§r§e!".toPattern() + private val melonRareDropPattern = + "§9§lRARE DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Melon§r§e!".toPattern() + private val melonCrazyRareDropPattern = + "§d§lCRAZY RARE DROP! §r§eDicer dropped §r§[a|9](\\d+)x §r§[a|9]Enchanted Melon(?: Block)?§r§e!".toPattern() + private val melonRngesusDropPattern = + "§5§lPRAY TO RNGESUS DROP! §r§eDicer dropped §r§9(\\d+)x §r§9Enchanted Melon Block§r§e!".toPattern() + + private val pumpkinUncommonDropPattern = + "§a§lUNCOMMON DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Pumpkin§r§e!".toPattern() + private val pumpkinRareDropPattern = + "§9§lRARE DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Pumpkin§r§e!".toPattern() + private val pumpkinCrazyRareDropPattern = + "§d§lCRAZY RARE DROP! §r§eDicer dropped §r§a(\\d+)x §r§aEnchanted Pumpkin§r§e!".toPattern() + private val pumpkinRngesusDropPattern = + "§5§lPRAY TO RNGESUS DROP! §r§eDicer dropped §r§[a|9](\\d+)x §r§(aEnchanted|9Polished) Pumpkin§r§e!".toPattern() + + init { + itemDrops.add(ItemDrop(CropType.MELON, DropRarity.UNCOMMON, melonUncommonDropPattern)) + itemDrops.add(ItemDrop(CropType.MELON, DropRarity.RARE, melonRareDropPattern)) + itemDrops.add(ItemDrop(CropType.MELON, DropRarity.CRAZY_RARE, melonCrazyRareDropPattern)) + itemDrops.add(ItemDrop(CropType.MELON, DropRarity.PRAY_TO_RNGESUS, melonRngesusDropPattern)) + + itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.UNCOMMON, pumpkinUncommonDropPattern)) + itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.RARE, pumpkinRareDropPattern)) + itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.CRAZY_RARE, pumpkinCrazyRareDropPattern)) + itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.PRAY_TO_RNGESUS, pumpkinRngesusDropPattern)) + } + + enum class DropRarity(val displayName: String) { + UNCOMMON("§a§lUNCOMMON DROP"), + RARE("§9§lRARE DROP"), + CRAZY_RARE("§d§lCRAZY RARE DROP"), + PRAY_TO_RNGESUS("§5§lPRAY TO RNGESUS DROP"), + } + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + if (!GardenAPI.inGarden()) return + if (!config.hideChat && !config.display) return + + val message = event.message + for (drop in itemDrops) { + drop.pattern.matchMatcher(message) { + addDrop(drop.crop, drop.rarity) + if (config.hideChat) { + event.blockedReason = "dicer_drop_tracker" + } + return + } + } + } + + private fun drawDisplay(storage: Data) = buildList> { + val cropInHand = cropInHand ?: return@buildList + val items = storage.drops.getOrPut(cropInHand) { mutableMapOf() } + addAsSingletonList("§7Dicer Rng Drop Tracker for $toolName§7:") + for ((rarity, amount) in items.sortedDesc()) { + val displayName = rarity.displayName + addAsSingletonList(" §7- §e${amount.addSeparators()}x $displayName") + } + + } + + private var cropInHand: CropType? = null + private var toolName = "" + + @SubscribeEvent + fun onGardenToolChange(event: GardenToolChangeEvent) { + val crop = event.crop + cropInHand = if (crop == CropType.MELON || crop == CropType.PUMPKIN) crop else null + if (cropInHand != null) { + toolName = event.toolItem!!.name!! + } + tracker.update() + } + + private fun addDrop(crop: CropType, rarity: DropRarity) { + tracker.modify { + val map = it.drops.getOrPut(crop) { mutableMapOf() } + map.addOrPut(rarity, 1) + } + } + + @SubscribeEvent + fun onRenderOverlay(event: GuiRenderEvent) { + if (!isEnabled()) return + + tracker.renderDisplay(config.pos) + } + + class ItemDrop(val crop: CropType, val rarity: DropRarity, val pattern: Pattern) + + fun isEnabled() = GardenAPI.inGarden() && config.display + + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.move(3, "garden.dicerCounterDisplay", "garden.dicerCounters.display") + event.move(3, "garden.dicerCounterHideChat", "garden.dicerCounters.hideChat") + event.move(3, "garden.dicerCounterPos", "garden.dicerCounters.pos") + + event.move(7, "#profile.garden.dicerRngDrops", "#profile.garden.dicerDropTracker.drops") { old -> + val items: MutableMap> = mutableMapOf() + val oldItems = ConfigManager.gson.fromJson>(old, Map::class.java) + for ((internalName, amount) in oldItems) { + val split = internalName.split(".") + val crop = CropType.getByName(split[0]) + val rarityName = split[1] + val rarity = DropRarity.valueOf(rarityName) + items.getOrPut(crop) { mutableMapOf() }[rarity] = amount + } + + ConfigManager.gson.toJsonTree(items) + } + } + + fun resetCommand(args: Array) { + tracker.resetCommand(args, "shresetdicertracker") + } +} -- cgit