aboutsummaryrefslogtreecommitdiff
path: root/src/main
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
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')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Garden.java28
-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
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt6
6 files changed, 102 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index 938e9ce61..867a2bca9 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -266,6 +266,7 @@ class SkyHanniMod {
loadModule(GardenYawAndPitch())
loadModule(MovementSpeedDisplay())
loadModule(ChumBucketHider())
+ loadModule(GardenRecentTeleportPadsDisplay())
init()
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 93b25e726..168ed0ca0 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Garden.java
@@ -3,6 +3,7 @@ package at.hannibal2.skyhanni.config.features;
import at.hannibal2.skyhanni.config.core.config.Position;
import com.google.gson.annotations.Expose;
import io.github.moulberry.moulconfig.annotations.*;
+import io.github.moulberry.moulconfig.observer.Property;
import net.minecraft.client.Minecraft;
import org.lwjgl.input.Keyboard;
@@ -826,6 +827,33 @@ public class Garden {
public boolean teleportPadsInventoryNumbers = false;
@Expose
+ @ConfigOption(name = "Recent Teleport Pad Display", desc = "")
+ @Accordion
+ @ConfigAccordionId(id = 19)
+ public RecentTeleportPads teleportPadsRecentDisplay = new RecentTeleportPads();
+
+ public static class RecentTeleportPads {
+
+ @Expose
+ @ConfigOption(name = "Enabled", desc = "Show the recent teleport pads used in a display.")
+ @ConfigEditorBoolean
+ public boolean enabled = false;
+
+ @Expose
+ @ConfigOption(name = "Only Target", desc = "Hide the 'From' part of the display.")
+ @ConfigEditorBoolean
+ public Property<Boolean> onlyTarget = Property.of(false);
+
+ @Expose
+ @ConfigOption(name = "Hide Chat", desc = "Hide teleport pad chat messages.")
+ @ConfigEditorBoolean
+ public boolean hideChat = false;
+
+ @Expose
+ public Position pos = new Position(206, 158, false, true);
+ }
+
+ @Expose
@ConfigOption(name = "Anita Medal Profit", desc = "")
@ConfigEditorAccordion(id = 16)
public boolean anitaMedalProfit = false;
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()
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index 60062ed3c..84807dcca 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -256,6 +256,10 @@ object LorenzUtils {
}
fun <T> onToggle(vararg properties: Property<out T>, observer: Runnable) {
- onChange(*properties) { _, _ -> observer.run() }
+ onChange(*properties) { _, _ -> observer.run() }
+ }
+
+ fun <T> Property<out T>.onToggle(observer: Runnable) {
+ whenChanged { _, _ -> observer.run() }
}
} \ No newline at end of file