diff options
21 files changed, 689 insertions, 39 deletions
diff --git a/.idea/dictionaries/default_user.xml b/.idea/dictionaries/default_user.xml index b166e60d3..db27217cf 100644 --- a/.idea/dictionaries/default_user.xml +++ b/.idea/dictionaries/default_user.xml @@ -100,6 +100,7 @@ <w>hideparticles</w> <w>hoppity</w> <w>hoppity's</w> + <w>hoppitys</w> <w>horsezooka</w> <w>hotbar</w> <w>hotm</w> @@ -274,4 +275,4 @@ <w>yolkar</w> </words> </dictionary> -</component> +</component>
\ No newline at end of file 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 89d7bb9bb..50accf32c 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -30,6 +30,7 @@ import at.hannibal2.skyhanni.features.event.diana.InquisitorWaypointShare import at.hannibal2.skyhanni.features.event.diana.MythologicalCreatureTracker import at.hannibal2.skyhanni.features.event.hoppity.HoppityCollectionStats import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggLocations +import at.hannibal2.skyhanni.features.event.hoppity.HoppityEventSummary import at.hannibal2.skyhanni.features.event.jerry.frozentreasure.FrozenTreasureTracker import at.hannibal2.skyhanni.features.fishing.tracker.FishingProfitTracker import at.hannibal2.skyhanni.features.fishing.tracker.SeaCreatureTracker @@ -337,6 +338,10 @@ object Commands { "shtpinfested", "Teleports you to the nearest infested plot", ) { PestFinder.teleportNearestInfestedPlot() } + registerCommand( + "shhoppitystats", + "Look up stats for a Hoppity's Event (by SkyBlock year).\nRun standalone for a list of years that have stats." + ) { HoppityEventSummary.sendStatsMessage(it) } } private fun usersBugFix() { diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/dev/DebugConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/dev/DebugConfig.java index d6a0eb064..56a17dfb9 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/dev/DebugConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/dev/DebugConfig.java @@ -157,6 +157,11 @@ public class DebugConfig { @ConfigEditorBoolean public boolean neverFunnyTime = false; + @Expose + @ConfigOption(name = "Always Hoppity's", desc = "Always act as if Hoppity's Hunt is active.") + @ConfigEditorBoolean + public boolean alwaysHoppitys = false; + // Does not have a config element! @Expose public Position trackSoundPosition = new Position(0, 0); diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/event/EventConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/event/EventConfig.java index 251ce51ba..57d3e0699 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/event/EventConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/event/EventConfig.java @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.config.features.event; import at.hannibal2.skyhanni.config.features.event.bingo.BingoConfig; import at.hannibal2.skyhanni.config.features.event.diana.DianaConfig; +import at.hannibal2.skyhanni.config.features.event.hoppity.HoppityEggsConfig; import at.hannibal2.skyhanni.config.features.event.waypoints.LobbyWaypointsConfig; import at.hannibal2.skyhanni.config.features.event.winter.WinterConfig; import com.google.gson.annotations.Expose; diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/event/HoppityEggsConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/event/hoppity/HoppityEggsConfig.java index 386aa7021..50a5731a5 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/event/HoppityEggsConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/event/hoppity/HoppityEggsConfig.java @@ -1,8 +1,9 @@ -package at.hannibal2.skyhanni.config.features.event; +package at.hannibal2.skyhanni.config.features.event.hoppity; import at.hannibal2.skyhanni.config.FeatureToggle; import at.hannibal2.skyhanni.config.core.config.Position; import com.google.gson.annotations.Expose; +import io.github.notenoughupdates.moulconfig.annotations.Accordion; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorColour; import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDropdown; @@ -14,6 +15,11 @@ import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; public class HoppityEggsConfig { @Expose + @ConfigOption(name = "Event Summary", desc = "") + @Accordion + public HoppityEventSummaryConfig eventSummary = new HoppityEventSummaryConfig(); + + @Expose @ConfigOption(name = "Hoppity Waypoints", desc = "Toggle guess waypoints for Hoppity's Hunt.") @ConfigEditorBoolean @FeatureToggle diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/event/hoppity/HoppityEventSummaryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/event/hoppity/HoppityEventSummaryConfig.java new file mode 100644 index 000000000..618b15f7f --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/event/hoppity/HoppityEventSummaryConfig.java @@ -0,0 +1,73 @@ +package at.hannibal2.skyhanni.config.features.event.hoppity; + +import at.hannibal2.skyhanni.config.FeatureToggle; +import com.google.gson.annotations.Expose; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDraggableList; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorInfoText; +import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class HoppityEventSummaryConfig { + + @Expose + @ConfigOption(name = "Enabled", desc = "Show a summary of your Hoppity Hunt stats when the event is over.") + @ConfigEditorBoolean + @FeatureToggle + public boolean enabled = true; + + @Expose + @ConfigOption( + name = "Viewing Stats", + desc = "View current and past event stats at any time using §b/shhoppitystats§7." + ) + @ConfigEditorInfoText + public String commandInfo; + + @Expose + @ConfigOption( + name = "Stats List", + desc = "Drag text to change what displays in the summary card." + ) + @ConfigEditorDraggableList + public List<HoppityStat> statDisplayList = new ArrayList<>(Arrays.asList( + HoppityStat.MEAL_EGGS_FOUND, + HoppityStat.HOPPITY_RABBITS_BOUGHT, + HoppityStat.SIDE_DISH_EGGS, + HoppityStat.MILESTONE_RABBITS, + HoppityStat.EMPTY_1, + HoppityStat.NEW_RABBITS, + HoppityStat.EMPTY_2, + HoppityStat.DUPLICATE_RABBITS + )); + + public enum HoppityStat { + MEAL_EGGS_FOUND("§7You found §b45§7/§a47 §6Chocolate Meal Eggs§7."), + HOPPITY_RABBITS_BOUGHT("§7You bought §b7 §fRabbits §7from §aHoppity§7."), + SIDE_DISH_EGGS("§7You found §b4 §6§lSide Dish §r§6Eggs §7in the §6Chocolate Factory§7."), + MILESTONE_RABBITS("§7You claimed §b2 §6§lMilestone Rabbits§7."), + EMPTY_1(""), + NEW_RABBITS("§7Unique Rabbits: §b7\n §f1 §7- §a1 §7- §91 §7- §51 §7- §61 §7- §d1 §7- §b1"), + EMPTY_2(""), + DUPLICATE_RABBITS("§7Duplicate Rabbits: §c10\n §f4 §7- §a3 §7- §92 §7- §51 §7- §60 §7- §d0 §7- §b0\n §6+250,000,000 Chocolate"), + EMPTY_3(""), + STRAY_RABBITS("§7Stray Rabbits: §f20\n §f10 §7- §a6 §7- §93 §7- §51 §7- §60 §7- §d0 §7- §b0\n §6+8,000,000 Chocolate\n §c* §c§oRequires Stray Tracker being enabled to work."), + EMPTY_4(""), + TIME_IN_CF("§7You spent §b4h 36m §7in the §6Chocolate Factory§7."), + ; + + private final String display; + + HoppityStat(String display) { + this.display = display; + } + + @Override + public String toString() { + return display; + } + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java index 39ce4402b..51be4daf1 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java +++ b/src/main/java/at/hannibal2/skyhanni/config/storage/ProfileSpecificStorage.java @@ -13,6 +13,7 @@ import at.hannibal2.skyhanni.features.dungeon.DungeonFloor; import at.hannibal2.skyhanni.features.event.diana.DianaProfitTracker; import at.hannibal2.skyhanni.features.event.diana.MythologicalCreatureTracker; import at.hannibal2.skyhanni.features.event.hoppity.HoppityCollectionStats; +import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggType; import at.hannibal2.skyhanni.features.event.jerry.frozentreasure.FrozenTreasureTracker; import at.hannibal2.skyhanni.features.fame.UpgradeReminder; import at.hannibal2.skyhanni.features.fishing.tracker.FishingProfitTracker; @@ -39,6 +40,7 @@ import at.hannibal2.skyhanni.features.rift.area.westvillage.kloon.KloonTerminal; import at.hannibal2.skyhanni.features.skillprogress.SkillType; import at.hannibal2.skyhanni.features.slayer.SlayerProfitTracker; import at.hannibal2.skyhanni.utils.GenericWrapper; +import at.hannibal2.skyhanni.utils.LorenzRarity; import at.hannibal2.skyhanni.utils.LorenzVec; import at.hannibal2.skyhanni.utils.NEUInternalName; import at.hannibal2.skyhanni.utils.SimpleTimeMark; @@ -666,4 +668,38 @@ public class ProfileSpecificStorage { @Expose public UpgradeReminder.CommunityShopUpgrade communityShopProfileUpgrade = null; + + @Expose + public Map<Integer, HoppityEventStats> hoppityEventStats = new HashMap<>(); + + public static class HoppityEventStats { + @Expose + public Map<HoppityEggType, Integer> mealsFound = new HashMap<>(); + + @Expose + public Map<LorenzRarity, RabbitData> rabbitsFound = new HashMap<>(); + + public static class RabbitData { + @Expose + public int uniques = 0; + + @Expose + public int dupes = 0; + + @Expose + public int strays = 0; + } + + @Expose + public long dupeChocolateGained = 0; + + @Expose + public long strayChocolateGained = 0; + + @Expose + public long millisInCf = 0; + + @Expose + public boolean summarized = false; + } } diff --git a/src/main/java/at/hannibal2/skyhanni/events/hoppity/RabbitFoundEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/hoppity/RabbitFoundEvent.kt new file mode 100644 index 000000000..865f5a690 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/events/hoppity/RabbitFoundEvent.kt @@ -0,0 +1,14 @@ +package at.hannibal2.skyhanni.events.hoppity + +import at.hannibal2.skyhanni.api.event.SkyHanniEvent +import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggType + +class RabbitFoundEvent( + val eggType: HoppityEggType, + val duplicate: Boolean, + val rabbitName: String, + val chocGained: Long = 0, +) : SkyHanniEvent() { + override fun toString(): String = + "§fType§7: ${eggType.coloredName}\n§fDuplicate§7: §b$duplicate\n§fRabbit§7: $rabbitName\n§fChoc Gained§7: §6$chocGained" +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityAPI.kt new file mode 100644 index 000000000..5c63fe3a8 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityAPI.kt @@ -0,0 +1,175 @@ +package at.hannibal2.skyhanni.features.event.hoppity + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.hoppity.RabbitFoundEvent +import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggsManager.getEggType +import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI +import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule +import at.hannibal2.skyhanni.utils.InventoryUtils +import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.ItemUtils.itemName +import at.hannibal2.skyhanni.utils.LorenzRarity +import at.hannibal2.skyhanni.utils.LorenzRarity.DIVINE +import at.hannibal2.skyhanni.utils.RegexUtils.firstMatcher +import at.hannibal2.skyhanni.utils.RegexUtils.groupOrNull +import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher +import at.hannibal2.skyhanni.utils.SkyblockSeason +import net.minecraft.util.ChatComponentText +import net.minecraftforge.fml.common.eventhandler.EventPriority +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +@SkyHanniModule +object HoppityAPI { + + private var hoppityEggChat = mutableListOf<String>() + private var duplicate = false + private var lastRarity = "" + private var lastName = "" + private var newRabbit = false + private var lastChatMeal: HoppityEggType? = null + private var lastDuplicateAmount: Long? = null + private var rabbitBought = false + + val hoppityRarities by lazy { LorenzRarity.entries.filter { it <= DIVINE } } + + private fun resetChatData() { + this.hoppityEggChat = mutableListOf() + this.duplicate = false + this.newRabbit = false + this.lastRarity = "" + this.lastName = "" + this.lastChatMeal = null + this.lastDuplicateAmount = null + this.rabbitBought = false + } + + fun isHoppityEvent() = (SkyblockSeason.currentSeason == SkyblockSeason.SPRING || SkyHanniMod.feature.dev.debug.alwaysHoppitys) + + fun rarityByRabbit(rabbit: String): LorenzRarity? = hoppityRarities.firstOrNull { it.chatColorCode == rabbit.substring(0, 2) } + + /** + * REGEX-TEST: §f1st Chocolate Milestone + * REGEX-TEST: §915th Chocolate Milestone + * REGEX-TEST: §622nd Chocolate Milestone + */ + private val milestoneNamePattern by ChocolateFactoryAPI.patternGroup.pattern( + "rabbit.milestone", + "(?:§.)*?(?<milestone>\\d{1,2})[a-z]{2} Chocolate Milestone", + ) + + /** + * REGEX-TEST: §7Reach §6300B Chocolate §7all-time to + * REGEX-TEST: §7Reach §61k Chocolate §7all-time to unlock + */ + private val allTimeLorePattern by ChocolateFactoryAPI.patternGroup.pattern( + "milestone.alltime", + "§7Reach §6(?<amount>[\\d.MBk]*) Chocolate §7all-time.*", + ) + + /** + * REGEX-TEST: §7Spend §6150B Chocolate §7in the + * REGEX-TEST: §7Spend §62M Chocolate §7in the §6Chocolate + */ + private val shopLorePattern by ChocolateFactoryAPI.patternGroup.pattern( + "milestone.shop", + "§7Spend §6(?<amount>[\\d.MBk]*) Chocolate §7in.*", + ) + + fun fireSideDishMessage() { + LorenzChatEvent( + "§d§lHOPPITY'S HUNT §r§dYou found a §r§6§lSide Dish §r§6Egg §r§din the Chocolate Factory§r§d!", + ChatComponentText(""), + ).postAndCatch() + } + + @SubscribeEvent(priority = EventPriority.HIGH) + fun onSlotClick(event: GuiContainerEvent.SlotClickEvent) { + val index = event.slot?.slotIndex ?: return + if (index == -999) return + + val clickedStack = InventoryUtils.getItemsInOpenChest() + .find { it.slotNumber == event.slot.slotNumber && it.hasStack } + ?.stack ?: return + val nameText = (if (clickedStack.hasDisplayName()) clickedStack.displayName else clickedStack.itemName) + + milestoneNamePattern.matchMatcher(nameText) { + val itemLore = clickedStack.getLore() + if (!itemLore.any { it == "§eClick to claim!" }) return + + // Will never match both all time and shop patterns together + allTimeLorePattern.firstMatcher(clickedStack.getLore()) { + LorenzChatEvent( + "§d§lHOPPITY'S HUNT §r§dYou claimed a §r§6§lChocolate Milestone Rabbit §r§din the Chocolate Factory§r§d!", + ChatComponentText(""), + ).postAndCatch() + } + + shopLorePattern.firstMatcher(clickedStack.getLore()) { + LorenzChatEvent( + "§d§lHOPPITY'S HUNT §r§dYou claimed a §r§6§lShop Milestone Rabbit §r§din the Chocolate Factory§r§d!", + ChatComponentText(""), + ).postAndCatch() + } + } + } + + // Dumbed down version of the Compact Chat for Hoppity's, + // with the additional native context of side dishes + fun handleChat(event: LorenzChatEvent) { + HoppityEggsManager.eggFoundPatterns.forEach { + it.matchMatcher(event.message) { + resetChatData() + lastChatMeal = getEggType(event) + attemptFire(event) + } + } + + HoppityEggsManager.eggBoughtPattern.matchMatcher(event.message) { + if (group("rabbitname").equals(lastName)) { + rabbitBought = true + lastChatMeal = HoppityEggType.BOUGHT + attemptFire(event) + } + } + + HoppityEggsManager.rabbitFoundPattern.matchMatcher(event.message) { + // The only cases where "You found ..." will come in with more than 1 message, + // or empty for hoppityEggChat, is where the rabbit was purchased from hoppity, + // In the case of buying, we want to reset variables to a clean state during this capture, + // as the important capture for the purchased message is the final message in + // the chain; "You found [rabbit]" -> "Dupe/New Rabbit" -> "You bought [rabbit]" + if ((hoppityEggChat.isEmpty() || hoppityEggChat.size > 1)) { + resetChatData() + } + + lastName = group("name") + lastRarity = group("rarity") + attemptFire(event) + } + + HoppityEggsManager.newRabbitFound.matchMatcher(event.message) { + newRabbit = true + groupOrNull("other")?.let { + attemptFire(event) + return + } + attemptFire(event) + } + } + + fun attemptFire(event: LorenzChatEvent, lastDuplicateAmount: Long? = null) { + lastDuplicateAmount?.let { + this.lastDuplicateAmount = it + } + hoppityEggChat.add(event.message) + if (lastDuplicateAmount != null) { + this.duplicate = true + } + val lastChatMeal = lastChatMeal ?: return + if (hoppityEggChat.size == 3) { + RabbitFoundEvent(lastChatMeal, duplicate, lastName, lastDuplicateAmount ?: 0).post() + } + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggDisplayManager.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggDisplayManager.kt index f09aa4eac..fe908e58f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggDisplayManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggDisplayManager.kt @@ -76,7 +76,7 @@ object HoppityEggDisplayManager { if (ReminderUtils.isBusy() && !config.showWhileBusy) return emptyList() val displayList = - HoppityEggType.entries.map { "§7 - ${it.formattedName} ${it.timeUntil().format()}" }.toMutableList() + HoppityEggType.resettingEntries.map { "§7 - ${it.formattedName} ${it.timeUntil().format()}" }.toMutableList() displayList.add(0, "§bUnclaimed Eggs:") if (config.showCollectedLocationCount && LorenzUtils.inSkyBlock) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt index dcf56aac6..d15d43d81 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggLocator.kt @@ -9,7 +9,6 @@ import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent import at.hannibal2.skyhanni.events.ReceiveParticleEvent import at.hannibal2.skyhanni.features.fame.ReminderUtils import at.hannibal2.skyhanni.features.garden.GardenAPI -import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule import at.hannibal2.skyhanni.utils.ColorUtils.toChromaColor import at.hannibal2.skyhanni.utils.InventoryUtils @@ -278,7 +277,7 @@ object HoppityEggLocator { type == EnumParticleTypes.ENCHANTMENT_TABLE && speed == -2.0f && count == 10 fun isEnabled() = LorenzUtils.inSkyBlock && config.waypoints && !GardenAPI.inGarden() && - !ReminderUtils.isBusy(true) && ChocolateFactoryAPI.isHoppityEvent() + !ReminderUtils.isBusy(true) && HoppityAPI.isHoppityEvent() private val ItemStack.isLocatorItem get() = getInternalName() == locatorItem diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggType.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggType.kt index 2846262e6..23e00cf88 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggType.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggType.kt @@ -14,9 +14,14 @@ enum class HoppityEggType( BREAKFAST("Breakfast", "§6", 7), LUNCH("Lunch", "§9", 14), DINNER("Dinner", "§a", 21), + SIDE_DISH("Side Dish", "§6§l", -1), + BOUGHT("Bought", "§a", -1), + CHOCOLATE_SHOP_MILESTONE("Shop Milestone", "§6", -1), + CHOCOLATE_FACTORY_MILESTONE("Chocolate Milestone", "§6", -1) ; fun timeUntil(): Duration { + if (resetsAt == -1) return Duration.INFINITE val now = SkyBlockTime.now() if (now.hour >= resetsAt) { return now.copy(day = now.day + 1, hour = resetsAt, minute = 0, second = 0) @@ -38,7 +43,9 @@ enum class HoppityEggType( val coloredName get() = "$mealColor$mealName" companion object { - fun allFound() = entries.forEach { it.markClaimed() } + val resettingEntries = entries.filter { it.resetsAt != -1 } + + fun allFound() = resettingEntries.forEach { it.markClaimed() } fun getMealByName(mealName: String) = entries.find { it.mealName == mealName } @@ -47,7 +54,7 @@ enum class HoppityEggType( val currentSbDay = currentSbTime.day val currentSbHour = currentSbTime.hour - for (eggType in entries) { + for (eggType in resettingEntries) { if (currentSbHour < eggType.resetsAt || eggType.lastResetDay == currentSbDay) continue eggType.markSpawned() eggType.lastResetDay = currentSbDay @@ -60,11 +67,11 @@ enum class HoppityEggType( } fun eggsRemaining(): Boolean { - return entries.any { !it.claimed } + return resettingEntries.any { !it.claimed } } fun allEggsRemaining(): Boolean { - return entries.all { !it.claimed } + return resettingEntries.all { !it.claimed } } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsCompactChat.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsCompactChat.kt index 35f87d7da..6bc1c8dfc 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsCompactChat.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsCompactChat.kt @@ -1,7 +1,11 @@ package at.hannibal2.skyhanni.features.event.hoppity -import at.hannibal2.skyhanni.config.features.event.HoppityEggsConfig +import at.hannibal2.skyhanni.config.features.event.hoppity.HoppityEggsConfig import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggType.CHOCOLATE_FACTORY_MILESTONE +import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggType.CHOCOLATE_SHOP_MILESTONE +import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggType.SIDE_DISH +import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggsManager.eggFoundPatterns import at.hannibal2.skyhanni.features.event.hoppity.HoppityEggsManager.getEggType import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI import at.hannibal2.skyhanni.utils.ChatUtils @@ -67,7 +71,10 @@ object HoppityEggsCompactChat { private fun createCompactMessage(): String { val mealName = lastChatMeal?.coloredName ?: "" - val mealNameFormatted = if (rabbitBought) "§aBought Rabbit" else "$mealName Egg" + val mealNameFormatted = if (rabbitBought) "§aBought Rabbit" + else if (lastChatMeal == SIDE_DISH) "§6§lSide Dish §r§6Egg" + else if (lastChatMeal == CHOCOLATE_SHOP_MILESTONE || lastChatMeal == CHOCOLATE_FACTORY_MILESTONE) "§6§lMilestone Rabbit" + else "$mealName Egg" val rarityConfig = HoppityEggsManager.config.rarityInCompact return if (duplicate) { @@ -86,10 +93,12 @@ object HoppityEggsCompactChat { } fun handleChat(event: LorenzChatEvent) { - HoppityEggsManager.eggFoundPattern.matchMatcher(event.message) { - resetCompactData() - lastChatMeal = getEggType(event) - compactChat(event) + eggFoundPatterns.forEach { + it.matchMatcher(event.message) { + resetCompactData() + lastChatMeal = getEggType(event) + compactChat(event) + } } HoppityEggsManager.eggBoughtPattern.matchMatcher(event.message) { @@ -100,12 +109,12 @@ object HoppityEggsCompactChat { } HoppityEggsManager.rabbitFoundPattern.matchMatcher(event.message) { - // The only case where "You found ..." will come in with more than 1 message, - // or empty for hoppityEggChat, is where the rabbit was purchased from hoppity - // in this case, we want to reset variables to a clean state during this capture, + // The only cases where "You found ..." will come in with more than 1 message, + // or empty for hoppityEggChat, is where the rabbit was purchased from hoppity, + // In the case of buying, we want to reset variables to a clean state during this capture, // as the important capture for the purchased message is the final message in // the chain; "You found [rabbit]" -> "Dupe/New Rabbit" -> "You bought [rabbit]" - if (hoppityEggChat.isEmpty() || hoppityEggChat.size > 1) { + if ((hoppityEggChat.isEmpty() || hoppityEggChat.size > 1)) { resetCompactData() } @@ -130,7 +139,9 @@ object HoppityEggsCompactChat { } } - fun clickableCompact(onClick: () -> Unit): Boolean = if (hoppityEggChat.isNotEmpty()) { + fun clickableCompact(onClick: () -> Unit): Boolean = if (hoppityEggChat.isNotEmpty() && !rabbitBought && lastChatMeal != null && + HoppityEggType.resettingEntries.contains(lastChatMeal) + ) { val hover = hoppityEggChat.joinToString("\n") + " \n§eClick here to share the location of this chocolate egg with the server!" hoppityEggChat.clear() ChatUtils.clickableChat( diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsManager.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsManager.kt index 93ae797e7..fcf4b17f0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/HoppityEggsManager.kt @@ -25,6 +25,7 @@ import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.TimeUtils.format import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.regex.Matcher +import java.util.regex.Pattern import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds @@ -37,13 +38,37 @@ object HoppityEggsManager { * REGEX-TEST: §d§lHOPPITY'S HUNT §r§dYou found a §r§9Chocolate Lunch Egg §r§don a ledge next to the stairs up§r§d! * REGEX-TEST: §d§lHOPPITY'S HUNT §r§dYou found a §r§aChocolate Dinner Egg §r§dbehind Emissary Sisko§r§d! * REGEX-TEST: §d§lHOPPITY'S HUNT §r§dYou found a §r§9Chocolate Lunch Egg §r§dnear the Diamond Essence Shop§r§d! + * REGEX-TEST: §d§lHOPPITY'S HUNT §r§dYou found a §r§6§lSide Dish §r§6Egg §r§din the Chocolate Factory§r§d! */ - val eggFoundPattern by ChocolateFactoryAPI.patternGroup.pattern( + private val eggFoundPattern by ChocolateFactoryAPI.patternGroup.pattern( "egg.found", "§d§lHOPPITY'S HUNT §r§dYou found a §r§.Chocolate (?<meal>\\w+) Egg §r§d(?<note>.*)§r§d!", ) /** + * REGEX-TEST: §d§lHOPPITY'S HUNT §r§dYou found a §r§6§lSide Dish §r§6Egg §r§din the Chocolate Factory§r§d! + */ + private val sideDishEggFoundPattern by ChocolateFactoryAPI.patternGroup.pattern( + "sidedish.found", + "§d§lHOPPITY'S HUNT §r§dYou found a §r§6§l(?<meal>.*) §r§6Egg §r§din the Chocolate Factory§r§d!", + ) + |
