aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-05-03 21:05:41 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-05-03 21:05:41 +0200
commit94521196a742a211594a1fdd29fa4dab9cbfb41f (patch)
tree8be33ad785ea72d631cf1474a8b991e35c537fff /src/main/java/at/hannibal2/skyhanni/features
parentf93585fe40a1dd2a1ccb2cbc160497af16006f86 (diff)
downloadskyhanni-94521196a742a211594a1fdd29fa4dab9cbfb41f.tar.gz
skyhanni-94521196a742a211594a1fdd29fa4dab9cbfb41f.tar.bz2
skyhanni-94521196a742a211594a1fdd29fa4dab9cbfb41f.zip
Added a recent teleport pad used display and option to hide teleport pad chat message
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt3
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenRecentTeleportPadsDisplay.kt64
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt4
3 files changed, 68 insertions, 3 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt
index 681b422fe..f49bcf1ed 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/bingo/BingoCardDisplay.kt
@@ -11,6 +11,7 @@ import at.hannibal2.skyhanni.utils.ItemUtils
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.onToggle
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
@@ -164,6 +165,6 @@ class BingoCardDisplay {
@SubscribeEvent
fun onConfigLoad(event: ConfigLoadEvent) {
- config.hideCommunityGoals.whenChanged { _, _ -> update() }
+ config.hideCommunityGoals.onToggle { update() }
}
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenRecentTeleportPadsDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenRecentTeleportPadsDisplay.kt
new file mode 100644
index 000000000..0577088bd
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenRecentTeleportPadsDisplay.kt
@@ -0,0 +1,64 @@
+package at.hannibal2.skyhanni.features.garden
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.ConfigLoadEvent
+import at.hannibal2.skyhanni.events.GuiRenderEvent
+import at.hannibal2.skyhanni.events.LorenzChatEvent
+import at.hannibal2.skyhanni.utils.LorenzUtils.onToggle
+import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
+import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class GardenRecentTeleportPadsDisplay {
+ private val config get() = SkyHanniMod.feature.garden.teleportPadsRecentDisplay
+ private var display = listOf<String>()
+ private var recentTeleports = mutableListOf<Pair<String, String>>()
+ private val pattern =
+ "§aWarped from the §r(?<from>.*) Teleport Pad§r§a to the §r(?<to>.*) Teleport Pad§r§a!".toPattern()
+
+ @SubscribeEvent
+ fun onChat(event: LorenzChatEvent) {
+ if (!GardenAPI.inGarden()) return
+
+ pattern.matchMatcher(event.message) {
+ if (config.enabled) {
+ recentTeleports.add(Pair(group("from"), group("to")))
+ if (recentTeleports.size > 3) recentTeleports.removeFirst()
+ update()
+ }
+
+ if (config.hideChat) {
+ event.blockedReason = "recent_teleport_pads"
+ }
+ }
+ }
+
+ private fun update() {
+ display = buildList {
+ add("§6Recent TPs")
+ for ((from, to) in recentTeleports) {
+ if (config.onlyTarget.get()) {
+ add(to)
+ } else {
+ add(" $from §7-> $to")
+ }
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onConfigLoad(event: ConfigLoadEvent) {
+ config.onlyTarget.onToggle {
+ update()
+ }
+ }
+
+ @SubscribeEvent
+ fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) {
+ if (!isEnabled()) return
+
+ config.pos.renderStrings(display, posLabel = "Recent Teleport Pads Display")
+ }
+
+ fun isEnabled() = GardenAPI.inGarden() && config.enabled
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt
index fc97a4b51..3dbba1cfb 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/update/UpdateManager.kt
@@ -5,6 +5,7 @@ import at.hannibal2.skyhanni.config.features.About
import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.utils.LorenzLogger
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.onToggle
import io.github.moulberry.moulconfig.processor.MoulConfigProcessor
import io.github.moulberry.notenoughupdates.util.MinecraftExecutor
import moe.nea.libautoupdate.*
@@ -34,8 +35,7 @@ object UpdateManager {
@SubscribeEvent
fun onConfigLoad(event: ConfigLoadEvent) {
- SkyHanniMod.feature.about.updateStream.whenChanged { oldValue, newValue ->
- if (oldValue != newValue)
+ SkyHanniMod.feature.about.updateStream.onToggle {
reset()
}
}