aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorJordan <77755681+Jordyrat@users.noreply.github.com>2024-06-01 11:11:05 +0100
committerGitHub <noreply@github.com>2024-06-01 12:11:05 +0200
commit00c5d1604662af31bfbd3ed151764c414437b721 (patch)
tree7a7687744feb5d4114f0b25451e8c3074c8e761c /src/main/java
parent00f544af46a2eb5ef4d385be3025838c511a334b (diff)
downloadskyhanni-00c5d1604662af31bfbd3ed151764c414437b721.tar.gz
skyhanni-00c5d1604662af31bfbd3ed151764c414437b721.tar.bz2
skyhanni-00c5d1604662af31bfbd3ed151764c414437b721.zip
Improvement: Compact Dicer Tracker (#1735)
Co-authored-by: BuildTools <unconfigured@null.spigotmc.org> Co-authored-by: Cal <cwolfson58@gmail.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/garden/DicerRngDropTrackerConfig.java7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropTracker.kt48
2 files changed, 44 insertions, 11 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/garden/DicerRngDropTrackerConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/garden/DicerRngDropTrackerConfig.java
index c8ce586c7..55dab6c74 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/garden/DicerRngDropTrackerConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/garden/DicerRngDropTrackerConfig.java
@@ -6,6 +6,7 @@ import com.google.gson.annotations.Expose;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean;
import io.github.notenoughupdates.moulconfig.annotations.ConfigLink;
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption;
+import io.github.notenoughupdates.moulconfig.observer.Property;
public class DicerRngDropTrackerConfig {
@Expose
@@ -15,6 +16,12 @@ public class DicerRngDropTrackerConfig {
public boolean display = true;
@Expose
+ @ConfigOption(name = "Compact Format", desc = "Compact the Dicer RNG Drop Tracker Display.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public Property<Boolean> compact = Property.of(false);
+
+ @Expose
@ConfigOption(name = "Hide Chat", desc = "Hide the chat message when dropping a RNG Dicer drop.")
@ConfigEditorBoolean
@FeatureToggle
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropTracker.kt
index f0d86d8e5..63b3e9615 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropTracker.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropTracker.kt
@@ -2,17 +2,19 @@ package at.hannibal2.skyhanni.features.garden.farming
import at.hannibal2.skyhanni.config.ConfigManager
import at.hannibal2.skyhanni.config.ConfigUpdaterMigrator
+import at.hannibal2.skyhanni.events.ConfigLoadEvent
import at.hannibal2.skyhanni.events.GardenToolChangeEvent
import at.hannibal2.skyhanni.events.GuiRenderEvent
import at.hannibal2.skyhanni.events.LorenzChatEvent
import at.hannibal2.skyhanni.features.garden.CropType
import at.hannibal2.skyhanni.features.garden.GardenAPI
-import at.hannibal2.skyhanni.utils.CollectionUtils.addAsSingletonList
import at.hannibal2.skyhanni.utils.CollectionUtils.addOrPut
import at.hannibal2.skyhanni.utils.CollectionUtils.sortedDesc
+import at.hannibal2.skyhanni.utils.ConditionalUtils
import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.renderables.Renderable
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import at.hannibal2.skyhanni.utils.tracker.SkyHanniTracker
import at.hannibal2.skyhanni.utils.tracker.TrackerData
@@ -85,11 +87,11 @@ object DicerRngDropTracker {
itemDrops.add(ItemDrop(CropType.PUMPKIN, DropRarity.PRAY_TO_RNGESUS, pumpkinRngesusDropPattern))
}
- enum class DropRarity(val displayName: String) {
- UNCOMMON("§a§lUNCOMMON DROP"),
- RARE("§9§lRARE DROP"),
- CRAZY_RARE("§d§lCRAZY RARE DROP"),
- PRAY_TO_RNGESUS("§5§lPRAY TO RNGESUS DROP"),
+ enum class DropRarity(val colorCode: Char, val displayName: String) {
+ UNCOMMON('a', "UNCOMMON"),
+ RARE('9', "RARE"),
+ CRAZY_RARE('d', "CRAZY RARE"),
+ PRAY_TO_RNGESUS('5', "PRAY TO RNGESUS"),
}
@SubscribeEvent
@@ -109,13 +111,37 @@ object DicerRngDropTracker {
}
}
- private fun drawDisplay(data: Data) = buildList<List<Any>> {
+ @SubscribeEvent
+ fun onConfigLoad(event: ConfigLoadEvent) {
+ ConditionalUtils.onToggle(config.compact) {
+ tracker.update()
+ }
+ }
+
+ private fun drawDisplay(data: Data) = buildList {
val cropInHand = cropInHand ?: return@buildList
val items = data.drops.getOrPut(cropInHand) { mutableMapOf() }
- addAsSingletonList("§7Dicer RNG Drop Tracker for $toolName§7:")
- for ((rarity, amount) in items.sortedDesc()) {
- val displayName = rarity.displayName
- addAsSingletonList(" §7- §e${amount.addSeparators()}x $displayName")
+ val list = mutableListOf<Renderable>()
+ val topLine = mutableListOf<Renderable>()
+
+ topLine.add(Renderable.itemStack(cropInHand.icon))
+ topLine.add(Renderable.string("§7Dicer Tracker:"))
+ add(listOf(Renderable.horizontalContainer(topLine)))
+ if (config.compact.get()) {
+
+ val compactLine = items.sortedDesc().map { (rarity, amount) ->
+ "§${rarity.colorCode}${amount.addSeparators()}"
+ }.joinToString("§7/")
+ list.add(Renderable.string(compactLine))
+ add(listOf(Renderable.verticalContainer(list)))
+
+ } else {
+ for ((rarity, amount) in items.sortedDesc()) {
+ val colorCode = rarity.colorCode
+ val displayName = rarity.displayName
+ list.add(Renderable.string(" §7- §e${amount.addSeparators()}x §$colorCode$displayName"))
+ }
+ add(listOf(Renderable.verticalContainer(list)))
}
}