aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/event/HoppityEggsConfig.java2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/inventory/chocolatefactory/ChocolateFactoryConfig.java5
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/hoppity/MythicRabbitPetWarning.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBlockOpen.kt48
4 files changed, 58 insertions, 3 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/event/HoppityEggsConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/event/HoppityEggsConfig.java
index 7fb058dd8..0083b1343 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/event/HoppityEggsConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/event/HoppityEggsConfig.java
@@ -146,7 +146,7 @@ public class HoppityEggsConfig {
@Expose
@ConfigOption(
name = "Rabbit Pet Warning",
- desc = "Warn when using the Egglocator without having a §d§lMythic Rabbit Pet §7selected. " +
+ desc = "Warn when using the Egglocator without a §d§lMythic Rabbit Pet §7equipped. " +
"§eOnly enable this setting when you own a mythic Rabbit pet."
)
@ConfigEditorBoolean
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 7c6fb1b14..c1da5e511 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
@@ -216,4 +216,9 @@ public class ChocolateFactoryConfig {
@Accordion
public ChocolateFactoryCustomReminderConfig customReminder = new ChocolateFactoryCustomReminderConfig();
+ @Expose
+ @ConfigOption(name = "Mythic Rabbit", desc = "Blocks running /cf without a §d§lMythic Rabbit Pet §7equipped.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean mythicRabbitRequirement = false;
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/MythicRabbitPetWarning.kt b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/MythicRabbitPetWarning.kt
index 59e951d21..8162f3a05 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/MythicRabbitPetWarning.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/hoppity/MythicRabbitPetWarning.kt
@@ -15,14 +15,16 @@ object MythicRabbitPetWarning {
if (lastCheck.passedSince() < 30.seconds) return
- if (!PetAPI.isCurrentPet(mythicRabbit)) {
+ if (!correctPet()) {
lastCheck = SimpleTimeMark.now()
warn()
}
}
+ fun correctPet() = PetAPI.isCurrentPet(mythicRabbit)
+
private fun warn() {
- ChatUtils.chat("Use a mythic Rabbit pet for more chocolate!")
+ ChatUtils.chat("Use a §dMythic Rabbit Pet §efor more chocolate!")
LorenzUtils.sendTitle("§cNo Rabbit Pet!", 3.seconds)
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBlockOpen.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBlockOpen.kt
new file mode 100644
index 000000000..74c1ca234
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/chocolatefactory/ChocolateFactoryBlockOpen.kt
@@ -0,0 +1,48 @@
+package at.hannibal2.skyhanni.features.inventory.chocolatefactory
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.MessageSendToServerEvent
+import at.hannibal2.skyhanni.features.event.hoppity.MythicRabbitPetWarning
+import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
+import at.hannibal2.skyhanni.utils.ChatUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.RegexUtils.matches
+import at.hannibal2.skyhanni.utils.SimpleTimeMark
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+import kotlin.time.Duration.Companion.seconds
+
+@SkyHanniModule
+object ChocolateFactoryBlockOpen {
+ private val config get() = SkyHanniMod.feature.inventory.chocolateFactory
+
+ /**
+ * REGEX-TEST: /cf
+ * REGEX-TEST: /cf test
+ * REGEX-TEST: /chocolatefactory
+ * REGEX-TEST: /chocolatefactory123456789
+ */
+ private val commandPattern by RepoPattern.pattern(
+ "inventory.chocolatefactory.opencommand",
+ "\\/(?:cf|chocolatefactory)(?: .*)?",
+ )
+
+ private var commandSentTimer = SimpleTimeMark.farPast()
+
+ @SubscribeEvent
+ fun onCommandSend(event: MessageSendToServerEvent) {
+ if (!isEnabled()) return
+ if (!commandPattern.matches(event.message)) return
+ if (commandSentTimer.passedSince() < 5.seconds) return
+ if (MythicRabbitPetWarning.correctPet()) return
+
+ commandSentTimer = SimpleTimeMark.now()
+ event.cancel()
+ ChatUtils.chatAndOpenConfig(
+ "Blocked opening the Chocolate Factory without a §dMythic Rabbit Pet §eequipped. Click here to disable!",
+ config::mythicRabbitRequirement,
+ )
+ }
+
+ private fun isEnabled() = LorenzUtils.inSkyBlock && config.mythicRabbitRequirement
+}