feat: Add block breaking indicators to jade
This commit is contained in:
@@ -81,6 +81,7 @@ data class SBItemStack constructor(
|
||||
}
|
||||
val EMPTY = SBItemStack(SkyblockId.NULL, 0)
|
||||
|
||||
private val BREAKING_POWER_REGEX = "Breaking Power (?<power>[0-9]+)".toPattern()
|
||||
operator fun invoke(itemStack: ItemStack): SBItemStack {
|
||||
val skyblockId = itemStack.skyBlockId ?: SkyblockId.NULL
|
||||
return SBItemStack(
|
||||
@@ -349,6 +350,12 @@ data class SBItemStack constructor(
|
||||
|
||||
private var itemStack_: ItemStack? = null
|
||||
|
||||
val breakingPower: Int
|
||||
get() =
|
||||
BREAKING_POWER_REGEX.useMatch(asImmutableItemStack().loreAccordingToNbt.firstOrNull()?.string) {
|
||||
group("power").toInt()
|
||||
} ?: 0
|
||||
|
||||
private val itemStack: ItemStack
|
||||
get() {
|
||||
val itemStack = itemStack_ ?: run {
|
||||
|
||||
@@ -16,12 +16,13 @@ import kotlin.time.Duration.Companion.seconds
|
||||
inline fun <T> String.ifMatches(regex: Regex, block: (MatchResult) -> T): T? =
|
||||
regex.matchEntire(this)?.let(block)
|
||||
|
||||
inline fun <T> Pattern.useMatch(string: String, block: Matcher.() -> T): T? {
|
||||
inline fun <T> Pattern.useMatch(string: String?, block: Matcher.() -> T): T? {
|
||||
contract {
|
||||
callsInPlace(block, InvocationKind.AT_MOST_ONCE)
|
||||
}
|
||||
return matcher(string)
|
||||
.takeIf(Matcher::matches)
|
||||
return string
|
||||
?.let(this::matcher)
|
||||
?.takeIf(Matcher::matches)
|
||||
?.let(block)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user