diff options
Diffstat (limited to 'src/main/java')
5 files changed, 174 insertions, 61 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java index f954015ac..50230a6ae 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java @@ -71,11 +71,6 @@ public class ChocolateFactoryConfig { public boolean useMiddleClick = true; @Expose - @ConfigOption(name = "Rabbit Warning", desc = "Warn when the rabbit that needs to be clicked appears.") - @ConfigEditorBoolean - public boolean rabbitWarning = true; - - @Expose @ConfigOption( name = "Rabbit Crush Threshold", desc = "How close should you be to your barn capacity before being warned about needing to upgrade it." @@ -186,6 +181,11 @@ public class ChocolateFactoryConfig { public boolean onlyHighlightRequirementNotMet = true; @Expose + @ConfigOption(name = "Rabbit Warning", desc = "") + @Accordion + public ChocolateFactoryRabbitWarningConfig rabbitWarning = new ChocolateFactoryRabbitWarningConfig(); + + @Expose @ConfigOption(name = "Chocolate Shop Price", desc = "") @Accordion public ChocolateShopPriceConfig chocolateShopPrice = new ChocolateShopPriceConfig(); diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryRabbitWarningConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryRabbitWarningConfig.java new file mode 100644 index 000000000..ef39d5f6c --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryRabbitWarningConfig.java @@ -0,0 +1,41 @@ +package at.hannibal2.skyhanni.config.features.inventory.chocolatefactory; + +import at.hannibal2.skyhanni.utils.OSUtils; +import com.google.gson.annotations.Expose; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorButton; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider; +import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorText; +import io.github.notenoughupdates.moulconfig.annotations.ConfigOption; +import io.github.notenoughupdates.moulconfig.observer.Property; + +public class ChocolateFactoryRabbitWarningConfig { + + @Expose + @ConfigOption(name = "Rabbit Warning", desc = "Warn when the rabbit that needs to be clicked appears.") + @ConfigEditorBoolean + public boolean rabbitWarning = true; + + @Expose + @ConfigOption(name = "Special Rabbit Warning", desc = "Warn when a special rabbit that needs to be clicked appears. (Rabbit The Fish and Golden Rabbits.") + @ConfigEditorBoolean + public boolean specialRabbitWarning = true; + + @Expose + @ConfigOption(name = "Warning Sound", desc = "The sound that play for a special rabbit.\n" + + "§eYou can use custom sounds, put it in the skyhanni/sounds folder in your resource pack.\n" + + "§eThen write skyhanni:yourfilename\n" + + "§cMust be a .ogg file") + @ConfigEditorText + public Property<String> specialRabbitSound = Property.of("note.pling"); + + @Expose + @ConfigOption(name = "Repeat Sound", desc = "How many times the sound should be repeated.") + @ConfigEditorSlider(minValue = 1, maxValue = 20, minStep = 1) + public int repeatSound = 20; + + @ConfigOption(name = "Sounds", desc = "Click to open the list of available sounds.") + @ConfigEditorButton(buttonText = "OPEN") + public Runnable sounds = () -> OSUtils.openBrowser("https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/mapping-and-modding-tutorials/2213619-1-8-all-playsound-sound-arguments"); + +} diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/HoppityEggLocationsJson.kt b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/HoppityEggLocationsJson.kt index e4162b82b..82eadbd18 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/HoppityEggLocationsJson.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/HoppityEggLocationsJson.kt @@ -21,4 +21,5 @@ data class HoppityEggLocationsJson( @Expose val coachRabbitIndex: Int, @Expose val maxRabbits: Int, @Expose val maxPrestige: Int, + @Expose val specialRabbits: List<String>, ) diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryAPI.kt index 8b9ef3f2a..568f8f4fe 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryAPI.kt @@ -17,6 +17,7 @@ import at.hannibal2.skyhanni.utils.NumberUtil.formatLong import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher import at.hannibal2.skyhanni.utils.RegexUtils.matches import at.hannibal2.skyhanni.utils.SkyblockSeason +import at.hannibal2.skyhanni.utils.SoundUtils import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.UtilsPatterns import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern @@ -71,6 +72,9 @@ object ChocolateFactoryAPI { var bestAffordableSlot = -1 var bestPossibleSlot = -1 + var specialRabbitTextures = listOf<String>() + var warningSound = SoundUtils.createSound("note.pling", 1f) + @SubscribeEvent fun onInventoryOpen(event: InventoryFullyOpenedEvent) { if (!isEnabled()) return @@ -110,6 +114,7 @@ object ChocolateFactoryAPI { coachRabbitIndex = data.coachRabbitIndex maxRabbits = data.maxRabbits maxPrestige = data.maxPrestige + specialRabbitTextures = data.specialRabbits ChocolateFactoryUpgrade.updateIgnoredSlots() } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt index 3d052da7a..108c24451 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryDataLoader.kt @@ -1,10 +1,15 @@ package at.hannibal2.skyhanni.features.inventory.chocolatefactory +import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator +import at.hannibal2.skyhanni.events.ConfigLoadEvent import at.hannibal2.skyhanni.events.InventoryCloseEvent import at.hannibal2.skyhanni.events.InventoryUpdatedEvent import at.hannibal2.skyhanni.events.LorenzWorldChangeEvent +import at.hannibal2.skyhanni.features.inventory.chocolatefactory.ChocolateFactoryAPI.specialRabbitTextures +import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.getLore +import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils.round import at.hannibal2.skyhanni.utils.NumberUtil.formatDouble @@ -84,6 +89,14 @@ object ChocolateFactoryDataLoader { "rabbit.clickme", "§e§lCLICK ME!" ) + + /** + * REGEX-TEST: §6§lGolden Rabbit §8- §aStampede + */ + private val clickMeGoldenRabbitPattern by ChocolateFactoryAPI.patternGroup.pattern( + "rabbit.clickme.golden", + "§6§lGolden Rabbit §8- §a(?<name>.*)" + ) private val rabbitAmountPattern by ChocolateFactoryAPI.patternGroup.pattern( "rabbit.amount", "Rabbit \\S+ - \\[(?<amount>\\d+)].*" @@ -118,6 +131,23 @@ object ChocolateFactoryDataLoader { clearData() } + @SubscribeEvent + fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) { + event.move( + 46, + "inventory.chocolateFactory.rabbitWarning", + "inventory.chocolateFactory.rabbitWarning.rabbitWarning" + ) + } + + @SubscribeEvent + fun onConfigLoad(event: ConfigLoadEvent) { + val soundProperty = config.rabbitWarning.specialRabbitSound + ConditionalUtils.onToggle(soundProperty) { + ChocolateFactoryAPI.warningSound = SoundUtils.createSound(soundProperty.get(), 1f) + } + } + private fun clearData() { ChocolateFactoryAPI.inChocolateFactory = false ChocolateFactoryAPI.chocolateFactoryPaused = false @@ -281,84 +311,120 @@ object ChocolateFactoryDataLoader { private fun processItem(list: MutableList<ChocolateFactoryUpgrade>, item: ItemStack, slotIndex: Int) { if (slotIndex == ChocolateFactoryAPI.prestigeIndex) return - if (config.rabbitWarning && clickMeRabbitPattern.matches(item.name)) { - SoundUtils.playBeepSound() - ChocolateFactoryAPI.clickRabbitSlot = slotIndex - } + + handleRabbitWarnings(item, slotIndex) if (slotIndex !in ChocolateFactoryAPI.otherUpgradeSlots && slotIndex !in ChocolateFactoryAPI.rabbitSlots) return val itemName = item.name.removeColor() val lore = item.getLore() val upgradeCost = ChocolateFactoryAPI.getChocolateBuyCost(lore) - val averageChocolate = ChocolateAmount.averageChocPerSecond().round(2) val isMaxed = upgradeCost == null - var isRabbit = false - var level: Int? = null - var newAverageChocolate: Double? = null - - when (slotIndex) { - in ChocolateFactoryAPI.rabbitSlots -> { - level = rabbitAmountPattern.matchMatcher(itemName) { - group("amount").formatInt() - } ?: run { - if (unemployedRabbitPattern.matches(itemName)) 0 else null - } ?: return - isRabbit = true - - if (isMaxed) { - val rabbitUpgradeItem = ChocolateFactoryUpgrade(slotIndex, level, null, isRabbit = true) - list.add(rabbitUpgradeItem) - return - } - - val chocolateIncrease = ChocolateFactoryAPI.rabbitSlots[slotIndex] ?: 0 - newAverageChocolate = ChocolateAmount.averageChocPerSecond(rawPerSecondIncrease = chocolateIncrease) - } - - in ChocolateFactoryAPI.otherUpgradeSlots -> { - level = upgradeTierPattern.matchMatcher(itemName) { - group("tier").romanToDecimal() - } ?: run { - if (otherUpgradePattern.matches(itemName)) 0 else null - } ?: return + if (slotIndex in ChocolateFactoryAPI.rabbitSlots) { + handleRabbitSlot(list, itemName, slotIndex, isMaxed, upgradeCost, averageChocolate) + } else if (slotIndex in ChocolateFactoryAPI.otherUpgradeSlots) { + handleOtherUpgradeSlot(list, itemName, slotIndex, isMaxed, upgradeCost, averageChocolate) + } + } - if (slotIndex == ChocolateFactoryAPI.timeTowerIndex) this.profileStorage?.timeTowerLevel = level + private fun handleRabbitSlot( + list: MutableList<ChocolateFactoryUpgrade>, + itemName: String, + slotIndex: Int, + isMaxed: Boolean, + upgradeCost: Long?, + averageChocolate: Double, + ) { + val level = rabbitAmountPattern.matchMatcher(itemName) { + group("amount").formatInt() + } ?: run { + if (unemployedRabbitPattern.matches(itemName)) 0 else null + } ?: return + + if (isMaxed) { + val rabbitUpgradeItem = ChocolateFactoryUpgrade(slotIndex, level, null, isRabbit = true) + list.add(rabbitUpgradeItem) + return + } - if (isMaxed) { - val otherUpgrade = ChocolateFactoryUpgrade(slotIndex, level, null) - list.add(otherUpgrade) - return - } + val chocolateIncrease = ChocolateFactoryAPI.rabbitSlots[slotIndex] ?: 0 + val newAverageChocolate = ChocolateAmount.averageChocPerSecond(rawPerSecondIncrease = chocolateIncrease) + addUpgradeToList(list, slotIndex, level, upgradeCost, averageChocolate, newAverageChocolate, isRabbit = true) + } - newAverageChocolate = when (slotIndex) { - ChocolateFactoryAPI.timeTowerIndex -> ChocolateAmount.averageChocPerSecond( - includeTower = true - ) + private fun handleOtherUpgradeSlot( + list: MutableList<ChocolateFactoryUpgrade>, + itemName: String, + slotIndex: Int, + isMaxed: Boolean, + upgradeCost: Long?, + averageChocolate: Double, + ) { + val level = upgradeTierPattern.matchMatcher(itemName) { + group("tier").romanToDecimal() + } ?: run { + if (otherUpgradePattern.matches(itemName)) 0 else null + } ?: return + + if (slotIndex == ChocolateFactoryAPI.timeTowerIndex) { + this.profileStorage?.timeTowerLevel = level + } - ChocolateFactoryAPI.coachRabbitIndex -> ChocolateAmount.averageChocPerSecond( - baseMultiplierIncrease = 0.01 - ) + if (isMaxed) { + val otherUpgrade = ChocolateFactoryUpgrade(slotIndex, level, null) + list.add(otherUpgrade) + return + } - else -> { - val otherUpgrade = ChocolateFactoryUpgrade(slotIndex, level, upgradeCost) - list.add(otherUpgrade) - return - } - } + val newAverageChocolate = when (slotIndex) { + ChocolateFactoryAPI.timeTowerIndex -> ChocolateAmount.averageChocPerSecond(includeTower = true) + ChocolateFactoryAPI.coachRabbitIndex -> ChocolateAmount.averageChocPerSecond(baseMultiplierIncrease = 0.01) + else -> { + val otherUpgrade = ChocolateFactoryUpgrade(slotIndex, level, upgradeCost) + list.add(otherUpgrade) + return } } - if (level == null || newAverageChocolate == null || upgradeCost == null) return - val extra = (newAverageChocolate - averageChocolate).round(2) - val effectiveCost = (upgradeCost / extra).round(2) + addUpgradeToList(list, slotIndex, level, upgradeCost, averageChocolate, newAverageChocolate, isRabbit = false) + } + private fun addUpgradeToList( + list: MutableList<ChocolateFactoryUpgrade>, + slotIndex: Int, + level: Int, + upgradeCost: Long?, + averageChocolate: Double, + newAverageChocolate: Double, + isRabbit: Boolean, + ) { + val extra = (newAverageChocolate - averageChocolate).round(2) + val effectiveCost = (upgradeCost!! / extra).round(2) val upgrade = ChocolateFactoryUpgrade(slotIndex, level, upgradeCost, extra, effectiveCost, isRabbit = isRabbit) list.add(upgrade) } + private fun handleRabbitWarnings(item: ItemStack, slotIndex: Int) { + val isGoldenRabbit = clickMeGoldenRabbitPattern.matches(item.name) + val warningConfig = config.rabbitWarning + + if (clickMeRabbitPattern.matches(item.name) || isGoldenRabbit) { + if (config.rabbitWarning.rabbitWarning) { + SoundUtils.playBeepSound() + } + + if (warningConfig.specialRabbitWarning + && (isGoldenRabbit || item.getSkullTexture() in specialRabbitTextures) + ) { + SoundUtils.repeatSound(100, warningConfig.repeatSound, ChocolateFactoryAPI.warningSound) + } + + ChocolateFactoryAPI.clickRabbitSlot = slotIndex + } + } + private fun findBestUpgrades(list: MutableList<ChocolateFactoryUpgrade>) { val profileStorage = profileStorage ?: return |