aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
authorCalMWolfs <94038482+CalMWolfs@users.noreply.github.com>2023-07-04 20:17:58 +1000
committerGitHub <noreply@github.com>2023-07-04 12:17:58 +0200
commit1a38f3d79d6cdbe90455191712fa71f0ac1aa7e6 (patch)
tree5bbfc980878605a322965e84e4e17f1ce511059c /src/main/java/at
parenta8b5f0c4aaa918e4264beaa2c3295d25ef3b71ec (diff)
downloadskyhanni-1a38f3d79d6cdbe90455191712fa71f0ac1aa7e6.tar.gz
skyhanni-1a38f3d79d6cdbe90455191712fa71f0ac1aa7e6.tar.bz2
skyhanni-1a38f3d79d6cdbe90455191712fa71f0ac1aa7e6.zip
Merge pull request #284
* custom text box * grammar * renamed thing * may as well fix this here as well
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/Misc.java23
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/CustomTextBox.kt33
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt4
5 files changed, 62 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index dfaa3c34f..d863f5ee8 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -315,6 +315,7 @@ class SkyHanniMod {
loadModule(DungeonLividFinder)
loadModule(CruxTalismanDisplay)
loadModule(LaserParkour())
+ loadModule(CustomTextBox())
init()
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
index 497190529..4e69a2c92 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/Misc.java
@@ -553,6 +553,29 @@ public class Misc {
}
@Expose
+ @ConfigOption(name = "Custom Text box", desc = "")
+ @Accordion
+ public TextBox textBox = new TextBox();
+
+ public static class TextBox {
+
+ @Expose
+ @ConfigOption(name = "Enabled", desc = "Enables showing the textbox while in SkyBlock.")
+ @ConfigEditorBoolean
+ public boolean enabled = false;
+
+ @Expose
+ @ConfigOption(name = "Text", desc = "Enter text you want to display here.\n" +
+ "§eUse '&' as the colour code character.\n" +
+ "§eUse '\\n' as the line break character.")
+ @ConfigEditorText
+ public Property<String> text = Property.of("&aYour Text Here\n&bYour new line here");
+
+ @Expose
+ public Position position = new Position(10, 80, false, true);
+ }
+
+ @Expose
@ConfigOption(name = "Exp Bottles", desc = "Hides all the experience orbs lying on the ground.")
@ConfigEditorBoolean
public boolean hideExpBottles = false;
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/CustomTextBox.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/CustomTextBox.kt
new file mode 100644
index 000000000..7c05c6af1
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/CustomTextBox.kt
@@ -0,0 +1,33 @@
+package at.hannibal2.skyhanni.features.misc
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.events.ConfigLoadEvent
+import at.hannibal2.skyhanni.events.GuiRenderEvent
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.afterChange
+import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class CustomTextBox {
+ private val config get() = SkyHanniMod.feature.misc.textBox
+ private var display = listOf<String>()
+
+ @SubscribeEvent
+ fun onConfigLoad(event: ConfigLoadEvent) {
+ display = config.text.get().format()
+
+ config.text.afterChange {
+ display = format()
+ }
+ }
+
+ private fun String.format() = replace("&", "§").split("\\n").toList()
+
+ @SubscribeEvent
+ fun onRenderOverlay(event: GuiRenderEvent.GameOverlayRenderEvent) {
+ if (!config.enabled) return
+ if (!LorenzUtils.inSkyBlock) return
+
+ config.position.renderStrings(display, posLabel = "Custom Text Box")
+ }
+} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt
index c31135431..dfb4b6973 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/FrozenTreasureTracker.kt
@@ -162,7 +162,7 @@ class FrozenTreasureTracker {
if (!config.enabled) return
if (!onJerryWorkshop()) return
if (config.onlyInCave && !inGlacialCave()) return
- config.position.renderStringsAndItems(display, posLabel = "Visitor Stats")
+ config.position.renderStringsAndItems(display, posLabel = "Frozen Treasure Tracker")
}
private fun onJerryWorkshop() = LorenzUtils.inIsland(IslandType.WINTER)
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
index c1309d573..77a47b895 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt
@@ -275,6 +275,10 @@ object LorenzUtils {
whenChanged { _, _ -> observer.run() }
}
+ fun <T> Property<out T>.afterChange(observer: T.() -> Unit) {
+ whenChanged { _, new -> observer(new) }
+ }
+
fun <K, V> Map<K, V>.editCopy(function: MutableMap<K, V>.() -> Unit) =
toMutableMap().also { function(it) }.toMap()