aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorraaaaaven <168305416+raaaaaven@users.noreply.github.com>2024-05-29 21:44:20 +0100
committerGitHub <noreply@github.com>2024-05-29 22:44:20 +0200
commit21f92de676710c0c39d37056dada80af8266a9ba (patch)
tree039ca2b47cfcaae55f1d0c1763b395a0ad08b865 /src
parentcbaed5b6865d169ce7d49bb16b8c42aa5d68be94 (diff)
downloadskyhanni-21f92de676710c0c39d37056dada80af8266a9ba.tar.gz
skyhanni-21f92de676710c0c39d37056dada80af8266a9ba.tar.bz2
skyhanni-21f92de676710c0c39d37056dada80af8266a9ba.zip
Feature: Added ULTRA RARE Book Notification. (#1738)
Co-authored-by: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Co-authored-by: raven <raveeeennnn@hotmail.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/inventory/helper/HelperConfig.java20
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/SuperpairsClicksAlert.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/misc/SuperpairsClicksAlert.kt)10
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/UltraRareBookAlert.kt102
6 files changed, 134 insertions, 10 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index c8a4c04dc..0374024e0 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -275,6 +275,8 @@ import at.hannibal2.skyhanni.features.inventory.ShiftClickNPCSell
import at.hannibal2.skyhanni.features.inventory.SkyblockGuideHighlightFeature
import at.hannibal2.skyhanni.features.inventory.StatsTuning
import at.hannibal2.skyhanni.features.inventory.SuperCraftFeatures
+import at.hannibal2.skyhanni.features.inventory.SuperpairsClicksAlert
+import at.hannibal2.skyhanni.features.inventory.UltraRareBookAlert
import at.hannibal2.skyhanni.features.inventory.auctionhouse.AuctionHouseCopyUnderbidPrice
import at.hannibal2.skyhanni.features.inventory.auctionhouse.AuctionHouseOpenPriceWebsite
import at.hannibal2.skyhanni.features.inventory.bazaar.BazaarApi
@@ -362,7 +364,6 @@ import at.hannibal2.skyhanni.features.misc.ReplaceRomanNumerals
import at.hannibal2.skyhanni.features.misc.RestorePieceOfWizardPortalLore
import at.hannibal2.skyhanni.features.misc.ServerRestartTitle
import at.hannibal2.skyhanni.features.misc.SkyBlockKickDuration
-import at.hannibal2.skyhanni.features.misc.SuperpairsClicksAlert
import at.hannibal2.skyhanni.features.misc.TabWidgetSettings
import at.hannibal2.skyhanni.features.misc.TimeFeatures
import at.hannibal2.skyhanni.features.misc.TpsCounter
@@ -888,6 +889,7 @@ class SkyHanniMod {
loadModule(Translator())
loadModule(CosmeticFollowingLine())
loadModule(SuperpairsClicksAlert())
+ loadModule(UltraRareBookAlert)
loadModule(PowderTracker)
loadModule(ModifyVisualWords)
loadModule(TabListReader)
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt
index fadaec07f..b44153e79 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt
@@ -12,7 +12,7 @@ import com.google.gson.JsonPrimitive
object ConfigUpdaterMigrator {
val logger = LorenzLogger("ConfigMigration")
- const val CONFIG_VERSION = 45
+ const val CONFIG_VERSION = 46
fun JsonElement.at(chain: List<String>, init: Boolean): JsonElement? {
if (chain.isEmpty()) return this
if (this !is JsonObject) return null
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/helper/HelperConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/helper/HelperConfig.java
index 0960c46b5..e117004a4 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/helper/HelperConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/helper/HelperConfig.java
@@ -51,4 +51,24 @@ public class HelperConfig {
@ConfigOption(name = "Tia Relay Abiphone Network Maintenance", desc = "")
@Accordion
public TiaRelayConfig tiaRelay = new TiaRelayConfig();
+
+ @Expose
+ @ConfigOption(name = "Enchanting", desc = "")
+ @Accordion
+ public EnchantingConfig enchanting = new EnchantingConfig();
+
+ public static class EnchantingConfig {
+ @Expose
+ @ConfigOption(name = "Superpairs Clicks Alert", desc = "Display an alert when you reach the maximum clicks gained from Chronomatron or Ultrasequencer.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean superpairsClicksAlert = false;
+
+ @Expose
+ @ConfigOption(name = "ULTRA-RARE Book Alert", desc = "Sends a chat message, title and sound when you find an ULTRA-RARE book.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean ultraRareBookAlert = false;
+ }
+
}
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java
index 6e4fe4f12..1921d64b3 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/misc/MiscConfig.java
@@ -199,12 +199,6 @@ public class MiscConfig {
public boolean accountUpgradeReminder = true;
@Expose
- @ConfigOption(name = "Superpairs Clicks Alert", desc = "Display an alert when you reach the maximum clicks gained from Chronomatron or Ultrasequencer.")
- @ConfigEditorBoolean
- @FeatureToggle
- public boolean superpairsClicksAlert = false;
-
- @Expose
@ConfigOption(name = "NEU Heavy Pearls", desc = "Fixing NEU Heavy Pearl detection.")
@ConfigEditorBoolean
@FeatureToggle
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/SuperpairsClicksAlert.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/SuperpairsClicksAlert.kt
index b09a1dbff..e9c8a717b 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/SuperpairsClicksAlert.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/SuperpairsClicksAlert.kt
@@ -1,6 +1,7 @@
-package at.hannibal2.skyhanni.features.misc
+package at.hannibal2.skyhanni.features.inventory
import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
import at.hannibal2.skyhanni.events.InventoryOpenEvent
import at.hannibal2.skyhanni.events.InventoryUpdatedEvent
import at.hannibal2.skyhanni.utils.ChatUtils
@@ -11,7 +12,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
class SuperpairsClicksAlert {
- private val config get() = SkyHanniMod.feature.misc
+ private val config get() = SkyHanniMod.feature.inventory.helper.enchanting
private var roundsNeeded = -1
private val roundsNeededRegex = Regex("""(?:Chain|Series) of (\d+):""")
@@ -59,4 +60,9 @@ class SuperpairsClicksAlert {
roundsNeeded = -1
}
}
+
+ @SubscribeEvent
+ fun onConfigFix(event: ConfigUpdaterMigrator.ConfigFixEvent) {
+ event.move(46, "misc.superpairsClicksAlert", "inventory.helper.enchanting.superpairsClicksAlert")
+ }
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/UltraRareBookAlert.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/UltraRareBookAlert.kt
new file mode 100644
index 000000000..1d6af4e89
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/UltraRareBookAlert.kt
@@ -0,0 +1,102 @@
+package at.hannibal2.skyhanni.features.inventory
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.GuiRenderEvent
+import at.hannibal2.skyhanni.events.InventoryCloseEvent
+import at.hannibal2.skyhanni.events.InventoryUpdatedEvent
+import at.hannibal2.skyhanni.utils.ChatUtils
+import at.hannibal2.skyhanni.utils.ColorUtils.withAlpha
+import at.hannibal2.skyhanni.utils.InventoryUtils
+import at.hannibal2.skyhanni.utils.ItemUtils.getLore
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.RegexUtils.matches
+import at.hannibal2.skyhanni.utils.RenderUtils
+import at.hannibal2.skyhanni.utils.SimpleTimeMark
+import at.hannibal2.skyhanni.utils.SoundUtils.createSound
+import at.hannibal2.skyhanni.utils.SoundUtils.playSound
+import at.hannibal2.skyhanni.utils.renderables.Renderable
+import at.hannibal2.skyhanni.utils.renderables.RenderableUtils.renderXYAligned
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
+import net.minecraft.client.Minecraft
+import net.minecraft.client.gui.inventory.GuiContainer
+import net.minecraft.client.renderer.GlStateManager
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import java.awt.Color
+import kotlin.time.Duration.Companion.seconds
+
+object UltraRareBookAlert {
+
+ private val config get() = SkyHanniMod.feature.inventory.helper.enchanting
+ private val dragonSound by lazy { createSound("mob.enderdragon.growl", 1f) }
+
+ private val patternGroup = RepoPattern.group("data.enchanting")
+ private val superpairsGui by patternGroup.pattern(
+ "inventory.experimentstable.gui",
+ "Superpairs.*"
+ )
+ private val ultraRarePattern by patternGroup.pattern(
+ "inventory.experimentstable.ultrarare",
+ "§d§kXX§5 ULTRA-RARE BOOK! §d§kXX"
+ )
+ private val bookPattern by patternGroup.pattern(
+ "inventory.experimentstable.book",
+ "§9(?<enchant>.*)"
+ )
+
+ private var enchantsFound = false
+
+ private var lastNotificationTime = SimpleTimeMark.farPast()
+
+ private fun notification(enchantsName: String) {
+ lastNotificationTime = SimpleTimeMark.now()
+ dragonSound.playSound()
+ ChatUtils.chat("You have uncovered a §d§kXX§5 ULTRA-RARE BOOK! §d§kXX§e! You found: §9$enchantsName")
+ }
+
+ @SubscribeEvent
+ fun onRenderOverlay(event: GuiRenderEvent.ChestGuiOverlayRenderEvent) {
+ if (!LorenzUtils.inSkyBlock) return
+ if (!config.ultraRareBookAlert) return
+ if (!superpairsGui.matches(InventoryUtils.openInventoryName())) return
+ if (lastNotificationTime.passedSince() > 5.seconds) return
+ val gui = Minecraft.getMinecraft().currentScreen as? GuiContainer ?: return
+
+ GlStateManager.pushMatrix()
+ GlStateManager.translate(0f, -150f, 500f)
+
+ Renderable.drawInsideRoundedRect(
+ Renderable.string("§d§kXX§5 ULTRA-RARE BOOK! §d§kXX", 1.5),
+ Color(Color.DARK_GRAY.withAlpha(0), true),
+ horizontalAlign = RenderUtils.HorizontalAlignment.CENTER,
+ verticalAlign = RenderUtils.VerticalAlignment.CENTER,
+ ).renderXYAligned(0, 125, gui.width, gui.height)
+
+ GlStateManager.translate(0f, 150f, -500f)
+ GlStateManager.popMatrix()
+ }
+
+ @SubscribeEvent
+ fun onInventoryUpdated(event: InventoryUpdatedEvent) {
+ if (!LorenzUtils.inSkyBlock) return
+ if (!config.ultraRareBookAlert) return
+ if (enchantsFound) return
+ if (!superpairsGui.matches(event.inventoryName)) return
+
+ for (lore in event.inventoryItems.map { it.value.getLore() }) {
+ val firstLine = lore.firstOrNull() ?: continue
+ if (!ultraRarePattern.matches(firstLine)) continue
+ val bookNameLine = lore.getOrNull(2) ?: continue
+ bookPattern.matchMatcher(bookNameLine) {
+ val enchantsName = group("enchant")
+ notification(enchantsName)
+ enchantsFound = true
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onInventoryClose(event: InventoryCloseEvent) {
+ enchantsFound = false
+ }
+}