diff options
Diffstat (limited to 'src/main/java/at/hannibal2')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrapperMobArea.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/misc/trevor/CurrentMobArea.kt) | 4 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt | 57 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorMob.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorMobs.kt) | 2 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorSolver.kt | 19 |
4 files changed, 51 insertions, 31 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/CurrentMobArea.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrapperMobArea.kt index f8a7f7c4c..753920ed1 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/CurrentMobArea.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrapperMobArea.kt @@ -2,7 +2,7 @@ package at.hannibal2.skyhanni.features.misc.trevor import at.hannibal2.skyhanni.utils.LorenzVec -enum class CurrentMobArea(val location: String, val coordinates: LorenzVec) { +enum class TrapperMobArea(val location: String, val coordinates: LorenzVec) { OASIS("Oasis", LorenzVec(126.0, 77.0, -456.0)), GORGE("Mushroom Gorge", LorenzVec(300.0, 80.0, -509.0)), OVERGROWN("Overgrown Mushroom Cave", LorenzVec(242.0, 60.0, -389.0)), @@ -11,4 +11,4 @@ enum class CurrentMobArea(val location: String, val coordinates: LorenzVec) { MOUNTAIN("Desert Mountain", LorenzVec(255.0, 148.0, -518.0)), FOUND(" ", LorenzVec(0.0, 0.0, 0.0)), NONE(" ", LorenzVec(0.0, 0.0, 0.0)), -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt index 45a8c2f89..7fe10ae5d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt @@ -31,6 +31,7 @@ import at.hannibal2.skyhanni.utils.RenderUtils.drawString import at.hannibal2.skyhanni.utils.RenderUtils.renderString import at.hannibal2.skyhanni.utils.SimpleTimeMark import at.hannibal2.skyhanni.utils.SoundUtils +import at.hannibal2.skyhanni.utils.StringUtils.findMatcher import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher import at.hannibal2.skyhanni.utils.StringUtils.removeColor import at.hannibal2.skyhanni.utils.TabListData @@ -65,7 +66,23 @@ object TrevorFeatures { ) private val locationPattern by patternGroup.pattern( "zone", - "Zone: (?<zone>.*)" + "Location: (?<zone>.*)" + ) + private val mobDiedPattern by patternGroup.pattern( + "mob.died", + "§aReturn to the Trapper soon to get a new animal to hunt!" + ) + private val startDialoguePattern by patternGroup.pattern( + "start.dialogue", + "[NPC] Trevor: You will have 10 minutes to find the mob from when you accept the task." + ) + private val outOfTimePattern by patternGroup.pattern( + "outoftime", + "You ran out of time and the animal disappeared!" + ) + private val clickOptionPattern by patternGroup.pattern( + "clickoption", + "Click an option: §r§a§l\\[YES]§r§7 - §r§c§l\\[NO]" ) private var timeUntilNextReady = 0 @@ -107,14 +124,14 @@ object TrevorFeatures { val formattedMessage = event.message.removeColor() - if (event.message == "§aReturn to the Trapper soon to get a new animal to hunt!") { + mobDiedPattern.matchMatcher(event.message) { TrevorSolver.resetLocation() if (config.trapperMobDiedMessage) { LorenzUtils.sendTitle("§2Mob Died ", 5.seconds) SoundUtils.playBeepSound() } trapperReady = true - TrevorSolver.mobLocation = CurrentMobArea.NONE + TrevorSolver.mobLocation = TrapperMobArea.NONE if (timeUntilNextReady <= 0) { currentStatus = TrapperStatus.READY currentLabel = "§2Ready" @@ -122,7 +139,7 @@ object TrevorFeatures { currentStatus = TrapperStatus.WAITING currentLabel = if (timeUntilNextReady == 1) "§31 second left" else "§3$timeUntilNextReady seconds left" } - TrevorSolver.mobLocation = CurrentMobArea.NONE + TrevorSolver.mobLocation = TrapperMobArea.NONE } trapperPattern.matchMatcher(formattedMessage) { @@ -147,15 +164,15 @@ object TrevorFeatures { TrevorSolver.averageHeight = LocationUtils.playerLocation().y } - if (formattedMessage == "[NPC] Trevor: You will have 10 minutes to find the mob from when you accept the task.") { + startDialoguePattern.matchMatcher(formattedMessage) { teleportBlock = SimpleTimeMark.now() } + outOfTimePattern.matchMatcher(formattedMessage) { + resetTrapper() + } - if (event.message.contains("§r§7Click an option: §r§a§l[YES]§r§7 - §r§c§l[NO]")) { - - val siblings = event.chatComponent.siblings - - for (sibling in siblings) { + clickOptionPattern.findMatcher(event.message) { + event.chatComponent.siblings.forEach { sibling -> if (sibling.chatStyle.chatClickEvent != null && sibling.chatStyle.chatClickEvent.value.contains("YES")) { lastChatPromptTime = SimpleTimeMark.now() lastChatPrompt = sibling.chatStyle.chatClickEvent.value.drop(1) @@ -207,18 +224,18 @@ object TrevorFeatures { active = true } - CurrentMobArea.entries.firstOrNull { it.location == formattedLine }?.let { + TrapperMobArea.entries.firstOrNull { it.location == formattedLine }?.let { TrevorSolver.mobLocation = it found = true } locationPattern.matchMatcher(formattedLine) { val zone = group("zone") - TrevorSolver.mobLocation = CurrentMobArea.entries.firstOrNull { it.location == zone } - ?: CurrentMobArea.NONE + TrevorSolver.mobLocation = TrapperMobArea.entries.firstOrNull { it.location == zone } + ?: TrapperMobArea.NONE found = true } } - if (!found) TrevorSolver.mobLocation = CurrentMobArea.NONE + if (!found) TrevorSolver.mobLocation = TrapperMobArea.NONE if (!active) { trapperReady = true } else { @@ -247,11 +264,11 @@ object TrevorFeatures { if (config.trapperSolver) { var location = TrevorSolver.mobLocation.coordinates - if (TrevorSolver.mobLocation == CurrentMobArea.NONE) return + if (TrevorSolver.mobLocation == TrapperMobArea.NONE) return if (TrevorSolver.averageHeight != 0.0) { location = LorenzVec(location.x, TrevorSolver.averageHeight, location.z) } - if (TrevorSolver.mobLocation == CurrentMobArea.FOUND) { + if (TrevorSolver.mobLocation == TrapperMobArea.FOUND) { val displayName = if (TrevorSolver.currentMob == null) "Mob Location" else { TrevorSolver.currentMob!!.mobName } @@ -300,8 +317,7 @@ object TrevorFeatures { } } - @SubscribeEvent - fun onWorldChange(event: LorenzWorldChangeEvent) { + private fun resetTrapper() { TrevorSolver.resetLocation() currentStatus = TrapperStatus.READY currentLabel = "§2Ready" @@ -309,6 +325,11 @@ object TrevorFeatures { inBetweenQuests = false } + @SubscribeEvent + fun onWorldChange(event: LorenzWorldChangeEvent) { + resetTrapper() + } + enum class TrapperStatus(baseColor: LorenzColor) { READY(LorenzColor.DARK_GREEN), WAITING(LorenzColor.DARK_AQUA), diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorMobs.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorMob.kt index d04f6f285..b8a89fe2f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorMobs.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorMob.kt @@ -1,6 +1,6 @@ package at.hannibal2.skyhanni.features.misc.trevor -enum class TrevorMobs(val mobName: String, val renderDistance: Double) { +enum class TrevorMob(val mobName: String, val renderDistance: Double) { COW("Cow", 68.0), HORSE("Horse", 90.0), SHEEP("Sheep", 68.0), diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorSolver.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorSolver.kt index d73b79db4..36f7d595b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorSolver.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorSolver.kt @@ -16,14 +16,14 @@ import kotlin.time.Duration.Companion.seconds object TrevorSolver { - private val animalHealths = intArrayOf(100, 200, 500, 1000, 2000, 5000, 10000, 30000) + private val animalHealths = setOf(100, 200, 500, 1000, 2000, 5000, 10000, 30000) - var currentMob: TrevorMobs? = null + var currentMob: TrevorMob? = null private var maxHeight: Double = 0.0 private var minHeight: Double = 0.0 private var foundID = -1 var mobCoordinates = LorenzVec(0.0, 0.0, 0.0) - var mobLocation = CurrentMobArea.NONE + var mobLocation = TrapperMobArea.NONE var averageHeight = (minHeight + maxHeight) / 2 fun findMobHeight(height: Int, above: Boolean) { @@ -53,18 +53,18 @@ object TrevorSolver { if (entity is EntityOtherPlayerMP) continue val name = entity.name val entityHealth = if (entity is EntityLivingBase) entity.baseMaxHealth.derpy() else 0 - currentMob = TrevorMobs.entries.firstOrNull { it.mobName.contains(name) } + currentMob = TrevorMob.entries.firstOrNull { it.mobName.contains(name) } if (animalHealths.any { it == entityHealth } && currentMob != null) { if (foundID == entity.entityId) { val dist = entity.position.toLorenzVec().distanceToPlayer() - if ((currentMob == TrevorMobs.RABBIT || currentMob == TrevorMobs.SHEEP) && mobLocation == CurrentMobArea.OASIS) { - println("This is unfortunate") - } else canSee = entity.canBeSeen() && dist < currentMob!!.renderDistance + if ((currentMob == TrevorMob.RABBIT || currentMob == TrevorMob.SHEEP) && mobLocation == TrapperMobArea.OASIS) return + + canSee = entity.canBeSeen() && dist < currentMob!!.renderDistance if (canSee) { - if (mobLocation != CurrentMobArea.FOUND) { + if (mobLocation != TrapperMobArea.FOUND) { LorenzUtils.sendTitle("§2Saw ${currentMob!!.mobName}!", 3.seconds) } - mobLocation = CurrentMobArea.FOUND + mobLocation = TrapperMobArea.FOUND mobCoordinates = entity.position.toLorenzVec() } } else { @@ -74,7 +74,6 @@ object TrevorSolver { } } if (foundID != -1) { - println("Cannot find mob anymore") mobCoordinates = LorenzVec(0.0, 0.0, 0.0) foundID = -1 } |