aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-11-07 23:07:53 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-11-07 23:07:53 +0100
commitcfc760103dc914d5b7456e9cffe06d30f396e029 (patch)
treeac07020c6c2047ab278de448205cd0aeea2d7092 /src/main/java/at/hannibal2
parent0f278dbc298769b47fd1c8eb58588aafbdcfb619 (diff)
downloadskyhanni-cfc760103dc914d5b7456e9cffe06d30f396e029.tar.gz
skyhanni-cfc760103dc914d5b7456e9cffe06d30f396e029.tar.bz2
skyhanni-cfc760103dc914d5b7456e9cffe06d30f396e029.zip
code cleanup and better wording
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt40
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/tracker/TrackerUtils.kt48
2 files changed, 32 insertions, 56 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt
index 8af683b16..6d0fcedb6 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniTracker.kt
@@ -3,9 +3,11 @@ package at.hannibal2.skyhanni.utils.tracker
import at.hannibal2.skyhanni.config.Storage
import at.hannibal2.skyhanni.config.core.config.Position
import at.hannibal2.skyhanni.data.ProfileStorageData
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList
import at.hannibal2.skyhanni.utils.LorenzUtils.addSelector
import at.hannibal2.skyhanni.utils.RenderUtils.renderStringsAndItems
-import at.hannibal2.skyhanni.utils.tracker.TrackerUtils.addSessionResetButton
+import at.hannibal2.skyhanni.utils.renderables.Renderable
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.inventory.GuiInventory
@@ -26,11 +28,19 @@ class SkyHanniTracker<Data : TrackerData>(
}
fun addSessionResetButton(list: MutableList<List<Any>>) {
- if (inventoryOpen && displayMode == DisplayMode.SESSION) {
- list.addSessionResetButton(name, getSharedTracker()) {
- update()
- }
- }
+ if (!inventoryOpen || displayMode != DisplayMode.SESSION) return
+
+ list.addAsSingletonList(
+ Renderable.clickAndHover(
+ "§cReset session!",
+ listOf(
+ "§cThis will reset your",
+ "§ccurrent session of",
+ "§c$name"
+ ),
+ ) {
+ reset(DisplayMode.SESSION, "§e[SkyHanni] Reset this session of $name!")
+ })
}
fun addDisplayModeToggle(list: MutableList<List<Any>>) {
@@ -50,9 +60,15 @@ class SkyHanniTracker<Data : TrackerData>(
fun currentDisplay() = getSharedTracker()?.get(displayMode)
fun resetCommand(args: Array<String>, command: String) {
- TrackerUtils.resetCommand(name, command, args, getSharedTracker()) {
- update()
+ if (args.size == 1 && args[0].lowercase() == "confirm") {
+ reset(DisplayMode.TOTAL, "§e[SkyHanni] Reset total $name!")
+ return
}
+
+ LorenzUtils.clickableChat(
+ "§e[SkyHanni] Are you sure you want to reset your total $name? Click here to confirm.",
+ "$command confirm"
+ )
}
fun modify(modifyFunction: (Data) -> Unit) {
@@ -68,4 +84,12 @@ class SkyHanniTracker<Data : TrackerData>(
position.renderStringsAndItems(display, posLabel = name)
}
+
+ private fun reset(displayMode: DisplayMode, message: String) {
+ getSharedTracker()?.get(displayMode)?.let {
+ it.reset()
+ LorenzUtils.chat(message)
+ update()
+ }
+ }
}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/tracker/TrackerUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/tracker/TrackerUtils.kt
deleted file mode 100644
index 77074a4b6..000000000
--- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/TrackerUtils.kt
+++ /dev/null
@@ -1,48 +0,0 @@
-package at.hannibal2.skyhanni.utils.tracker
-
-import at.hannibal2.skyhanni.utils.LorenzUtils
-import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList
-import at.hannibal2.skyhanni.utils.renderables.Renderable
-
-object TrackerUtils {
-
- fun MutableList<List<Any>>.addSessionResetButton(name: String, data: SharedTracker<*>?, update: () -> Unit) {
- addAsSingletonList(
- Renderable.clickAndHover(
- "§cReset session!",
- listOf(
- "§cThis will reset your",
- "§ccurrent session for",
- "§c$name"
- ),
- ) {
- data?.get(DisplayMode.SESSION)?.let {
- reset(it) {
- update()
- }
- }
- })
- }
-
- fun resetCommand(name: String, command: String, args: Array<String>, data: SharedTracker<*>?, update: () -> Unit) {
- if (args.size == 1 && args[0].lowercase() == "confirm") {
- reset(data?.get(DisplayMode.TOTAL)) {
- update()
- LorenzUtils.chat("§e[SkyHanni] You reset your $name data!")
- }
- return
- }
-
- LorenzUtils.clickableChat(
- "§e[SkyHanni] Are you sure you want to reset all your $name data? Click here to confirm.",
- "$command confirm"
- )
- }
-
- private fun reset(data: TrackerData?, update: () -> Unit) {
- data?.let {
- it.reset()
- update()
- }
- }
-}