aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/test
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal002@users.noreply.github.com>2024-03-06 23:51:02 +0100
committerGitHub <noreply@github.com>2024-03-06 23:51:02 +0100
commit0a95a791eb57a546fb5421594abae740faf1dfdb (patch)
tree82bfc13c544a60d496bab081b66ddd73e07d62a3 /src/main/java/at/hannibal2/skyhanni/test
parent28430fe85115334fb06fb7e3cc36da819f08dace (diff)
downloadskyhanni-0a95a791eb57a546fb5421594abae740faf1dfdb.tar.gz
skyhanni-0a95a791eb57a546fb5421594abae740faf1dfdb.tar.bz2
skyhanni-0a95a791eb57a546fb5421594abae740faf1dfdb.zip
Internal Changes: Many small code cleanups (#1101)
Co-authored-by: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/test')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/TestCopyBestiaryValues.kt13
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/command/CopyBossbarCommand.kt6
-rw-r--r--src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt4
3 files changed, 11 insertions, 12 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/test/TestCopyBestiaryValues.kt b/src/main/java/at/hannibal2/skyhanni/test/TestCopyBestiaryValues.kt
index 348d05cb2..03a0776ce 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/TestCopyBestiaryValues.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/TestCopyBestiaryValues.kt
@@ -8,10 +8,11 @@ import at.hannibal2.skyhanni.utils.ItemUtils.getLore
import at.hannibal2.skyhanni.utils.ItemUtils.getSkullOwner
import at.hannibal2.skyhanni.utils.ItemUtils.getSkullTexture
import at.hannibal2.skyhanni.utils.ItemUtils.name
-import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber
+import at.hannibal2.skyhanni.utils.NumberUtil.formatInt
import at.hannibal2.skyhanni.utils.OSUtils
import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
+import at.hannibal2.skyhanni.utils.StringUtils.removeWordsAtEnd
import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern
import com.google.gson.GsonBuilder
import com.google.gson.annotations.Expose
@@ -67,8 +68,7 @@ object TestCopyBestiaryValues {
}
private fun copy(titleItem: ItemStack, inventoryItems: Map<Int, ItemStack>) {
- val name = titleItem.name ?: return
- val titleName = name.split(" ").dropLast(1).joinToString(" ")
+ val titleName = titleItem.name.removeWordsAtEnd(1)
val obj = BestiarityObject()
obj.name = titleName
@@ -82,14 +82,13 @@ object TestCopyBestiaryValues {
return
}
val capLine = lore.nextAfter(overallProgress) ?: return
- val rawCap = capLine.substringAfter("/").removeColor().formatNumber()
- obj.cap = rawCap.toInt()
+ val rawCap = capLine.substringAfter("/").removeColor().formatInt()
+ obj.cap = rawCap
val mobs = mutableListOf<String>()
for (i in 10..43) {
val stack = inventoryItems[i] ?: continue
- val stackName = stack.name ?: continue
- bestiaryTypePattern.matchMatcher(stackName.removeColor()) {
+ bestiaryTypePattern.matchMatcher(stack.name.removeColor()) {
val lvl = group("lvl").toInt()
var text = group("text").lowercase().replace(" ", "_")
diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/CopyBossbarCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/CopyBossbarCommand.kt
index cac3ac02f..3b29821fd 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/command/CopyBossbarCommand.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/command/CopyBossbarCommand.kt
@@ -1,7 +1,7 @@
package at.hannibal2.skyhanni.test.command
import at.hannibal2.skyhanni.data.BossbarData
-import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.ChatUtils
import at.hannibal2.skyhanni.utils.OSUtils
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
@@ -11,10 +11,10 @@ object CopyBossbarCommand {
val bossbarName = if (noFormattingCodes) BossbarData.getBossbar().removeColor() else BossbarData.getBossbar()
val status = if (noFormattingCodes) "without" else "with"
if (bossbarName.isBlank()) {
- LorenzUtils.chat("Boss bar appears to be blank.")
+ ChatUtils.chat("Boss bar appears to be blank.")
} else {
OSUtils.copyToClipboard(bossbarName)
- LorenzUtils.chat("Boss bar name copied to clipboard $status formatting codes!")
+ ChatUtils.chat("Boss bar name copied to clipboard $status formatting codes!")
}
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt b/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt
index 4cd3a9bfd..bc1efc143 100644
--- a/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/test/command/ErrorManager.kt
@@ -54,9 +54,9 @@ object ErrorManager {
cache.clear()
}
- fun skyHanniError(message: String): Nothing {
+ fun skyHanniError(message: String, vararg extraData: Pair<String, Any?>): Nothing {
val exception = IllegalStateException(message)
- logErrorWithData(exception, message)
+ logErrorWithData(exception, message, extraData = extraData)
throw exception
}