-
-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Damage Indicator Ender Dragon (#3376)
Co-authored-by: hannibal2 <[email protected]>
- Loading branch information
1 parent
55da225
commit 5d1596b
Showing
3 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
86 changes: 86 additions & 0 deletions
86
src/main/java/at/hannibal2/skyhanni/features/combat/DragonFightAPI.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package at.hannibal2.skyhanni.features.combat | ||
|
||
import at.hannibal2.skyhanni.api.event.HandleEvent | ||
import at.hannibal2.skyhanni.data.hypixel.chat.event.SystemMessageEvent | ||
import at.hannibal2.skyhanni.events.ScoreboardUpdateEvent | ||
import at.hannibal2.skyhanni.events.minecraft.WorldChangeEvent | ||
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule | ||
import at.hannibal2.skyhanni.utils.NumberUtil.formatInt | ||
import at.hannibal2.skyhanni.utils.RegexUtils.matchMatcher | ||
import at.hannibal2.skyhanni.utils.StringUtils.removeColor | ||
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern | ||
|
||
@SkyHanniModule | ||
object DragonFightAPI { | ||
|
||
var currentType: String? = null | ||
var currentHp: Int? = null | ||
var yourDamage: Int? = null | ||
|
||
private val group = RepoPattern.group("combat.end-dragon-fight") | ||
|
||
/** | ||
* REGEX-TEST: ☬ The Wise Dragon has spawned! | ||
*/ | ||
private val chatSpawnPattern by group.pattern( | ||
"chat.spawn", | ||
"☬ The (?<type>.*) Dragon has spawned!", | ||
) | ||
|
||
/** | ||
* REGEX-TEST: YOUNG DRAGON DOWN! | ||
*/ | ||
private val chatDeath by group.pattern( | ||
"chat.death", | ||
".*DRAGON DOWN!", | ||
) | ||
|
||
/** | ||
* REGEX-TEST: Dragon HP: 4,824,217 ❤ | ||
*/ | ||
private val scoreboardHPPattern by group.pattern( | ||
"scoreboard.hp", | ||
"Dragon HP: (?<hp>.*) ❤", | ||
) | ||
|
||
/** | ||
* REGEX-TEST: Your Damage: 0 | ||
*/ | ||
private val scoreboardYourDamagePattern by group.pattern( | ||
"scoreboard.your-damage", | ||
"Your Damage: (?<damage>.*)", | ||
) | ||
|
||
@HandleEvent | ||
fun onChat(event: SystemMessageEvent) { | ||
chatSpawnPattern.matchMatcher(event.message.removeColor()) { | ||
currentType = group("type") | ||
} | ||
chatDeath.matchMatcher(event.message.removeColor()) { | ||
reset() | ||
} | ||
} | ||
|
||
fun reset() { | ||
currentType = null | ||
currentHp = null | ||
yourDamage = null | ||
} | ||
|
||
@HandleEvent | ||
fun onWorldChange(event: WorldChangeEvent) { | ||
reset() | ||
} | ||
|
||
@HandleEvent | ||
fun onScoreboardChange(event: ScoreboardUpdateEvent) { | ||
for (line in event.full.map { it.removeColor() }) { | ||
scoreboardHPPattern.matchMatcher(line) { | ||
currentHp = group("hp").formatInt() | ||
} | ||
scoreboardYourDamagePattern.matchMatcher(line) { | ||
yourDamage = group("damage").formatInt() | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters