aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-04-23 17:16:20 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-04-23 17:16:20 +0200
commit4e5d32ba8d743bbd5e7a1f854bd97874d681b2a4 (patch)
treee53d6600efa304fbe0d9fb9fb5cc2b450f07f8e9 /src/main/java/at/hannibal2
parentd16891c6c1e46ca8356deb5685f1551e32ecee45 (diff)
downloadskyhanni-4e5d32ba8d743bbd5e7a1f854bd97874d681b2a4.tar.gz
skyhanni-4e5d32ba8d743bbd5e7a1f854bd97874d681b2a4.tar.bz2
skyhanni-4e5d32ba8d743bbd5e7a1f854bd97874d681b2a4.zip
Hide chat messages from the visitors in garden. (Except Beth and Spaceman)
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Garden.java6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt25
2 files changed, 31 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java
index b6bb30838..7547d3e1b 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java
@@ -167,6 +167,12 @@ public class Garden {
public boolean visitorHypixelArrivedMessage = true;
@Expose
+ @ConfigOption(name = "Hide Chat", desc = "Hide chat messages from the visitors in garden. (Except Beth and Spaceman)")
+ @ConfigEditorBoolean
+ @ConfigAccordionId(id = 1)
+ public boolean visitorHideChat = true;
+
+ @Expose
@ConfigOption(name = "Numbers", desc = "")
@ConfigEditorAccordion(id = 5)
public boolean numbers = false;
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
index 3f27138b8..1bababdb1 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/GardenVisitorFeatures.kt
@@ -43,6 +43,7 @@ class GardenVisitorFeatures {
private val newVisitorArrivedMessage = ".* §r§ehas arrived on your §r§bGarden§r§e!".toPattern()
private val copperPattern = " §8\\+§c(.*) Copper".toPattern()
private val gardenExperiencePattern = " §8\\+§2(.*) §7Garden Experience".toPattern()
+ private val visitorChatMessagePattern = "§e\\[NPC] (§.)?(?<name>.*)§f: §r§f.*".toPattern()
private val config get() = SkyHanniMod.feature.garden
private val logger = LorenzLogger("garden/visitors")
@@ -462,6 +463,30 @@ class GardenVisitorFeatures {
event.blockedReason = "new_visitor_arrived"
}
}
+
+ if (GardenAPI.inGarden()) {
+ if (config.visitorHideChat) {
+ if (hideVisitorMessage(event.message)) {
+ event.blockedReason = "garden_visitor_message"
+ }
+ }
+ }
+ }
+
+ private fun hideVisitorMessage(message: String): Boolean {
+ val matcher = visitorChatMessagePattern.matcher(message)
+ if (!matcher.matches()) return false
+
+ val name = matcher.group("name")
+ if (name == "Spaceman") return false
+ if (name == "Beth") return false
+
+ if (visitors.keys.any { it.removeColor() == name }) {
+ println("blocked msg from '$name'")
+ return true
+ }
+
+ return false
}
private fun update() {