aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-09-02 12:13:17 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-09-02 12:13:17 +0200
commit966eaa282e604939b7e295279a5f0b22ba1c6e0f (patch)
tree22d8068f958f15aaf20c6c033df8505099473342 /src/main/java/at/hannibal2/skyhanni
parent312c06a8e042c780df1aacc942b4f042a3634e5b (diff)
downloadskyhanni-966eaa282e604939b7e295279a5f0b22ba1c6e0f.tar.gz
skyhanni-966eaa282e604939b7e295279a5f0b22ba1c6e0f.tar.bz2
skyhanni-966eaa282e604939b7e295279a5f0b22ba1c6e0f.zip
code cleanup, better error handling
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt6
2 files changed, 4 insertions, 4 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt
index 084c8d9e9..3bb3534e3 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt
@@ -39,7 +39,7 @@ enum class CropType(
return entries.firstOrNull { it.cropName == itemName }
}
- fun getByName(name: String) = getByNameOrNull(name) ?: throw RuntimeException("No valid crop type '$name'")
+ fun getByName(name: String) = getByNameOrNull(name) ?: error("No valid crop type '$name'")
fun IBlockState.getCropType(): CropType? {
return when (block) {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt
index 30473f39f..7a993f0de 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/FarmingWeightDisplay.kt
@@ -409,13 +409,13 @@ class FarmingWeightDisplay {
private fun CropType.getLocalCounter() = localCounter[this] ?: 0L
private fun CropType.getFactor(): Double {
- return factorPerCrop[this] ?: backupFactors[this]!!
+ return factorPerCrop[this] ?: backupFactors[this] ?: error("Crop $this not in backupFactors!")
}
fun lookUpCommand(it: Array<String>) {
val name = if (it.size == 1) it[0] else LorenzUtils.getPlayerName()
OSUtils.openBrowser("https://elitebot.dev/@$name/")
- LorenzUtils.chat("§e[SkyHanni] Opening Farming Profile from §b$name")
+ LorenzUtils.chat("§e[SkyHanni] Opening Farming Profile of player §b$name")
}
private val factorPerCrop = mutableMapOf<CropType, Double>()
@@ -430,7 +430,7 @@ class FarmingWeightDisplay {
val result = withContext(Dispatchers.IO) { APIUtil.getJSONResponse(url) }.asJsonObject
for (crop in result.entrySet()) {
- val cropType = CropType.entries.firstOrNull { it.cropName == crop.key } ?: continue
+ val cropType = CropType.getByName(crop.key)
factorPerCrop[cropType] = crop.value.asDouble
}
}