aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
authorHiZe <superhize@hotmail.com>2024-01-22 20:03:56 +0100
committerGitHub <noreply@github.com>2024-01-22 20:03:56 +0100
commit9afe501f5d7bdeeb91999944d414d6a31445fad2 (patch)
tree713aa42ca27b0713f72ba07e43dca044a6f07c89 /src/main/java/at/hannibal2/skyhanni
parent822913b506c63f8a322af76d3460a961e22b845c (diff)
downloadskyhanni-9afe501f5d7bdeeb91999944d414d6a31445fad2.tar.gz
skyhanni-9afe501f5d7bdeeb91999944d414d6a31445fad2.tar.bz2
skyhanni-9afe501f5d7bdeeb91999944d414d6a31445fad2.zip
Add: Dojo Rank Display (#775)
Added Dojo Rank Display. #775
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/crimsonisle/CrimsonIsleConfig.java11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java1
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/BeltsJson.java10
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/inventory/DojoRankDisplay.kt92
5 files changed, 116 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index 7662c666e..bb2684db7 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -201,6 +201,7 @@ import at.hannibal2.skyhanni.features.garden.visitor.HighlightVisitorsOutsideOfG
import at.hannibal2.skyhanni.features.garden.visitor.VisitorListener
import at.hannibal2.skyhanni.features.inventory.AuctionsHighlighter
import at.hannibal2.skyhanni.features.inventory.ChestValue
+import at.hannibal2.skyhanni.features.inventory.DojoRankDisplay
import at.hannibal2.skyhanni.features.inventory.HarpFeatures
import at.hannibal2.skyhanni.features.inventory.HideNotClickableItems
import at.hannibal2.skyhanni.features.inventory.HighlightBonzoMasks
@@ -712,6 +713,7 @@ class SkyHanniMod {
loadModule(PestSpawnTimer)
loadModule(PestFinder())
loadModule(SprayFeatures())
+ loadModule(DojoRankDisplay())
loadModule(SprayDisplay())
loadModule(HighlightPlaceableNpcs())
loadModule(PresentWaypoints())
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/crimsonisle/CrimsonIsleConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/crimsonisle/CrimsonIsleConfig.java
index 465816d5c..f46126ed6 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/crimsonisle/CrimsonIsleConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/crimsonisle/CrimsonIsleConfig.java
@@ -45,4 +45,15 @@ public class CrimsonIsleConfig {
@Expose
public Position positionVolcano = new Position(20, 20, false, true);
+
+ @Expose
+ @ConfigOption(name = "Dojo Rank Display", desc = "Display your rank, score, actual belt\n" +
+ "and points needed for the next belt in the Challenges inventory\n" +
+ "on the Crimson Isles.")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean showDojoRankDisplay = false;
+
+ @Expose
+ public Position dojoRankDisplayPosition = new Position(-378, 206, false, true);
}
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java
index b01498728..ab7c71831 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java
@@ -9,6 +9,7 @@ import io.github.moulberry.moulconfig.annotations.Category;
import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean;
import io.github.moulberry.moulconfig.annotations.ConfigEditorDraggableList;
import io.github.moulberry.moulconfig.annotations.ConfigOption;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
diff --git a/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/BeltsJson.java b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/BeltsJson.java
new file mode 100644
index 000000000..15aadc2d4
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/data/jsonobjects/repo/BeltsJson.java
@@ -0,0 +1,10 @@
+package at.hannibal2.skyhanni.data.jsonobjects.repo;
+
+import com.google.gson.annotations.Expose;
+
+import java.util.Map;
+
+public class BeltsJson {
+ @Expose
+ public Map<String, Integer> belts;
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/DojoRankDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/DojoRankDisplay.kt
new file mode 100644
index 000000000..1c91b8168
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/DojoRankDisplay.kt
@@ -0,0 +1,92 @@
+package at.hannibal2.skyhanni.features.inventory
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.IslandType
+import at.hannibal2.skyhanni.data.jsonobjects.repo.BeltsJson
+import at.hannibal2.skyhanni.events.GuiRenderEvent
+import at.hannibal2.skyhanni.events.InventoryCloseEvent
+import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
+import at.hannibal2.skyhanni.events.RepositoryReloadEvent
+import at.hannibal2.skyhanni.utils.ItemUtils.getLore
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.LorenzUtils.isInIsland
+import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
+import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
+import net.minecraft.item.ItemStack
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+class DojoRankDisplay {
+
+ private val config get() = SkyHanniMod.feature.crimsonIsle
+ private var display = emptyList<String>()
+ private val patternGroup = RepoPattern.group("inventory.dojo.rankdisplay")
+ private val testNamePattern by patternGroup.pattern("name", "(?<color>§\\w)Test of (?<name>.*)")
+ private val testRankPattern by patternGroup.pattern("rank", "(?:§\\w)+Your Rank: (?<rank>§\\w.) §8\\((?<score>\\d+)\\)")
+ private var belts = mapOf<String, Int>()
+
+ @SubscribeEvent
+ fun onRenderOverlay(event: GuiRenderEvent.ChestGuiOverlayRenderEvent) {
+ if (!isEnabled()) return
+ config.dojoRankDisplayPosition.renderStrings(display, posLabel = "Dojo Rank Display")
+ }
+
+ private fun drawDisplay(items: Collection<ItemStack>) = buildList {
+ if (belts.isEmpty()) {
+ add("§cUnable to get Belts data, please run /shupdaterepo")
+ return@buildList
+ }
+
+ var totalScore = 0
+ for (stack in items) {
+ val name = stack.displayName ?: continue
+ testNamePattern.matchMatcher(name) {
+ val testColor = group("color")
+ val testName = group("name")
+ for (line in stack.getLore()) {
+ testRankPattern.matchMatcher(line) {
+ val rank = group("rank")
+ val score = group("score").toInt()
+ val color = if (score in 0 .. 99) "§c" else "§a"
+ totalScore += score
+ add("$testColor$testName§f: $rank §7($color${score.addSeparators()}§7)")
+ }
+ }
+ }
+ }
+
+ val beltPoints = belts.toList()
+
+ val currentBelt = beltPoints.lastOrNull { totalScore >= it.second } ?: beltPoints.first()
+ val currentIndex = beltPoints.indexOf(currentBelt)
+ val nextBelt = beltPoints.getOrNull(currentIndex + 1) ?: beltPoints.first()
+ val pointsNeededForNextBelt = 0.coerceAtLeast(nextBelt.second.minus(totalScore))
+
+ add("§7Total Score: §6${totalScore.addSeparators()} §7(§8${currentBelt.first}§7)")
+
+ if (pointsNeededForNextBelt != 0)
+ add("§7Points needed for ${nextBelt.first}§f: §6${pointsNeededForNextBelt.addSeparators()}")
+ }
+
+ @SubscribeEvent
+ fun onInventoryOpen(event: InventoryFullyOpenedEvent) {
+ if (!isEnabled()) return
+ if (event.inventoryName != "Challenges") return
+ display = drawDisplay(event.inventoryItems.values)
+ }
+
+ @SubscribeEvent
+ fun onInventoryClose(event: InventoryCloseEvent) {
+ display = emptyList()
+ }
+
+ @SubscribeEvent
+ fun onRepoReload(event: RepositoryReloadEvent) {
+ val data = event.getConstant<BeltsJson>("Belts")
+ belts = data.belts
+ }
+
+ private fun isEnabled() =
+ IslandType.CRIMSON_ISLE.isInIsland() && LorenzUtils.skyBlockArea == "Dojo" && config.showDojoRankDisplay
+}