aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt31
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt44
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/CrimsonMiniBoss.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt49
4 files changed, 66 insertions, 62 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt
index 5ba40ed41..c86c968d1 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt
@@ -3,12 +3,12 @@ package at.hannibal2.skyhanni.features.nether.reputationhelper
import at.hannibal2.skyhanni.SkyHanniMod
import at.hannibal2.skyhanni.data.HyPixelData
import at.hannibal2.skyhanni.data.IslandType
-import at.hannibal2.skyhanni.events.FirstConfigLoadedEvent
+import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.features.nether.reputationhelper.dailyquest.DailyQuestHelper
-import at.hannibal2.skyhanni.features.nether.reputationhelper.miniboss.CrimsonMiniBoss
import at.hannibal2.skyhanni.features.nether.reputationhelper.miniboss.DailyMiniBossHelper
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.RenderUtils.renderStrings
+import com.google.gson.JsonObject
import net.minecraftforge.client.event.RenderGameOverlayEvent
import net.minecraftforge.fml.common.eventhandler.EventPriority
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
@@ -17,25 +17,30 @@ import net.minecraftforge.fml.common.gameevent.TickEvent
class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) {
val questHelper = DailyQuestHelper(this)
- private val miniBossHelper = DailyMiniBossHelper(this)
+ val miniBossHelper = DailyMiniBossHelper(this)
- val miniBosses = mutableListOf<CrimsonMiniBoss>()
+ var repoData: JsonObject = JsonObject()
private val display = mutableListOf<String>()
private var dirty = true
+ private var loaded = false
init {
skyHanniMod.loadModule(questHelper)
skyHanniMod.loadModule(miniBossHelper)
+ }
- miniBosses.add(CrimsonMiniBoss("Magma Boss"))
- miniBosses.add(CrimsonMiniBoss("Mage Outlaw"))
- miniBosses.add(CrimsonMiniBoss("Barbarian Duke X"))
+ @SubscribeEvent
+ fun onRepoReload(event: RepositoryReloadEvent) {
+ repoData = event.getConstant("CrimsonIsleReputation")!!
+ if (!loaded) {
+ loaded = true
- miniBosses.add(CrimsonMiniBoss("Bladesoul"))
- miniBosses.add(CrimsonMiniBoss("Ashfang"))
+ miniBossHelper.init()
- miniBossHelper.init()
+ questHelper.loadConfig()
+ miniBossHelper.loadConfig()
+ }
}
@SubscribeEvent
@@ -48,12 +53,6 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) {
}
}
- @SubscribeEvent
- fun onFirstConfigLoaded(event: FirstConfigLoadedEvent) {
- questHelper.loadConfig()
- miniBossHelper.loadConfig()
- }
-
private fun updateRender() {
display.clear()
diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt
index 7a50a483e..b4a8e4200 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/dailyquest/QuestLoader.kt
@@ -55,7 +55,7 @@ class QuestLoader(val dailyQuestHelper: DailyQuestHelper) {
if (oldQuest.state != QuestState.READY_TO_COLLECT && oldQuest.state != QuestState.COLLECTED) {
oldQuest.state = QuestState.READY_TO_COLLECT
dailyQuestHelper.update()
- LorenzUtils.debug("Tablist updated ${oldQuest.internalName} (This should not happen)")
+ LorenzUtils.debug("Reputation Helper: Tab-List updated ${oldQuest.internalName} (This should not happen)")
}
}
return
@@ -71,33 +71,33 @@ class QuestLoader(val dailyQuestHelper: DailyQuestHelper) {
state: QuestState,
needAmount: Int
): Quest {
-
- //TODO add repo
-
- //Trophy Fish
- if (name == "Lavahorse") return TrophyFishQuest(name, state, needAmount)
- if (name == "Gusher") return TrophyFishQuest(name, state, needAmount)
- if (name == "Volcanic Stonefish") return TrophyFishQuest(name, state, needAmount)
-
- //Rescue Mission
- if (name == "Rescue Mission") return RescueMissionQuest(state)
-
- for (miniBoss in dailyQuestHelper.reputationHelper.miniBosses) {
+ for (miniBoss in dailyQuestHelper.reputationHelper.miniBossHelper.miniBosses) {
if (name == miniBoss.displayName) {
return MiniBossQuest(miniBoss, state, needAmount)
}
}
- //Fetch
- if (name == "Magmag") return FetchQuest(name, state, needAmount)
- if (name == "Spectre Dust") return FetchQuest(name, state, needAmount)
- if (name == "Tentacle Meat") return FetchQuest(name, state, needAmount)
+ for (entry in dailyQuestHelper.reputationHelper.repoData.entrySet()) {
+ val category = entry.key
+
+ for (element in entry.value.asJsonArray) {
+ val entryName = element.asString
- if (name.startsWith("Mastery Rank ") || name.startsWith("Tenacity Rank ") || name.startsWith("Stamina Rank ")) {
- val split = name.split(" Rank ")
- val dojoName = split[0]
- val dojoRankGoal = split[1]
- return DojoQuest(dojoName, dojoRankGoal, state)
+ if (name.startsWith("$entryName Rank ")) {
+ val split = name.split(" Rank ")
+ val dojoName = split[0]
+ val dojoRankGoal = split[1]
+ return DojoQuest(dojoName, dojoRankGoal, state)
+ }
+
+ if (name == entryName) {
+ when (category) {
+ "FISHING" -> return TrophyFishQuest(name, state, needAmount)
+ "RESCUE" -> return RescueMissionQuest(state)
+ "FETCH" -> return FetchQuest(name, state, needAmount)
+ }
+ }
+ }
}
println("Unknown quest: '$name'")
diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/CrimsonMiniBoss.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/CrimsonMiniBoss.kt
index 917ed5784..d8ea3bd2e 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/CrimsonMiniBoss.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/CrimsonMiniBoss.kt
@@ -1,3 +1,5 @@
package at.hannibal2.skyhanni.features.nether.reputationhelper.miniboss
-class CrimsonMiniBoss(val displayName: String) \ No newline at end of file
+import java.util.regex.Pattern
+
+class CrimsonMiniBoss(val displayName: String, val pattern: Pattern, var doneToday: Boolean = false, ) \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt
index a4568363b..9e72ff2c5 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/miniboss/DailyMiniBossHelper.kt
@@ -11,14 +11,18 @@ import java.util.regex.Pattern
class DailyMiniBossHelper(private val reputationHelper: CrimsonIsleReputationHelper) {
- private val miniBossesDoneToday = mutableMapOf<CrimsonMiniBoss, Boolean>()
- private val miniBossesPatterns = mutableMapOf<CrimsonMiniBoss, Pattern>()
+ val miniBosses = mutableListOf<CrimsonMiniBoss>()
fun init() {
- for (miniBoss in reputationHelper.miniBosses) {
- miniBossesDoneToday[miniBoss] = false
- val patterns = " *§r§6§l${miniBoss.displayName.uppercase()} DOWN!"
- miniBossesPatterns[miniBoss] = Pattern.compile(patterns)
+ if (miniBosses.isNotEmpty()) return
+
+ val repoData = reputationHelper.repoData
+ val jsonElement = repoData["MINIBOSS"]
+ val asJsonArray = jsonElement.asJsonArray
+ for (entry in asJsonArray) {
+ val displayName = entry.asString
+ val patterns = " *§r§6§l${displayName.uppercase()} DOWN!"
+ miniBosses.add(CrimsonMiniBoss(displayName, Pattern.compile(patterns)))
}
}
@@ -28,10 +32,9 @@ class DailyMiniBossHelper(private val reputationHelper: CrimsonIsleReputationHel
if (LorenzUtils.skyBlockIsland != IslandType.CRIMSON_ISLE) return
val message = event.message
- for (entry in miniBossesPatterns) {
- val pattern = entry.value
- if (pattern.matcher(message).matches()) {
- finished(entry.key)
+ for (miniBoss in miniBosses) {
+ if (miniBoss.pattern.matcher(message).matches()) {
+ finished(miniBoss)
}
}
}
@@ -39,50 +42,50 @@ class DailyMiniBossHelper(private val reputationHelper: CrimsonIsleReputationHel
private fun finished(miniBoss: CrimsonMiniBoss) {
LorenzUtils.debug("Detected mini boss death: ${miniBoss.displayName}")
reputationHelper.questHelper.finishMiniBoss(miniBoss)
- miniBossesDoneToday[miniBoss] = true
+ miniBoss.doneToday = true
reputationHelper.update()
}
fun render(display: MutableList<String>) {
- val done = miniBossesDoneToday.count { it.value }
+ val done = miniBosses.count { it.doneToday }
// val sneaking = Minecraft.getMinecraft().thePlayer.isSneaking
// if (done != 5 || sneaking) {
if (done != 5) {
display.add("")
display.add("Daily Bosses ($done/5 killed)")
- for (entry in miniBossesDoneToday) {
- display.add(renderQuest(entry.key, entry.value))
+ for (miniBoss in miniBosses) {
+ display.add(renderQuest(miniBoss))
}
}
}
- private fun renderQuest(miniBoss: CrimsonMiniBoss, doneToday: Boolean): String {
- val color = if (doneToday) "§7Done" else "§bTodo"
+ private fun renderQuest(miniBoss: CrimsonMiniBoss): String {
+ val color = if (miniBoss.doneToday) "§7Done" else "§bTodo"
val displayName = miniBoss.displayName
return "$displayName: $color"
}
fun reset() {
- for (miniBoss in miniBossesDoneToday.keys) {
- miniBossesDoneToday[miniBoss] = false
+ for (miniBoss in miniBosses) {
+ miniBoss.doneToday = false
}
}
fun saveConfig() {
SkyHanniMod.feature.hidden.crimsonIsleMiniBossesDoneToday.clear()
- for (entry in miniBossesDoneToday) {
- if (entry.value) {
- SkyHanniMod.feature.hidden.crimsonIsleMiniBossesDoneToday.add(entry.key.displayName)
+ for (miniBoss in miniBosses) {
+ if (miniBoss.doneToday) {
+ SkyHanniMod.feature.hidden.crimsonIsleMiniBossesDoneToday.add(miniBoss.displayName)
}
}
}
fun loadConfig() {
for (name in SkyHanniMod.feature.hidden.crimsonIsleMiniBossesDoneToday) {
- miniBossesDoneToday[getByDisplayName(name)!!] = true
+ getByDisplayName(name)!!.doneToday = true
}
}
- private fun getByDisplayName(name: String) = miniBossesDoneToday.keys.firstOrNull { it.displayName == name }
+ private fun getByDisplayName(name: String) = miniBosses.firstOrNull { it.displayName == name }
} \ No newline at end of file