diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-08-28 19:18:20 +0200 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-08-28 19:18:20 +0200 |
commit | 225420a08a859ac1849dd7ea680d5c214453824e (patch) | |
tree | 8ca5afce32314b1a055b082ccd0a5ca0a77142d7 /src/main | |
parent | 7eb3e77e5ce50989af3cd4ab2b196fb0df76e168 (diff) | |
download | skyhanni-225420a08a859ac1849dd7ea680d5c214453824e.tar.gz skyhanni-225420a08a859ac1849dd7ea680d5c214453824e.tar.bz2 skyhanni-225420a08a859ac1849dd7ea680d5c214453824e.zip |
code cleanup and better error handling
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt | 16 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/test/command/CopyErrorCommand.kt | 7 |
2 files changed, 12 insertions, 11 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt index 53de2fa9a..c00e2c6e0 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/CropMoneyDisplay.kt @@ -14,6 +14,7 @@ import at.hannibal2.skyhanni.features.garden.GardenAPI import at.hannibal2.skyhanni.features.garden.GardenNextJacobContest import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.getSpeed import at.hannibal2.skyhanni.features.garden.farming.GardenCropSpeed.isSpeedDataEmpty +import at.hannibal2.skyhanni.test.command.CopyErrorCommand import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.ItemUtils.getItemNameOrNull import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList @@ -133,16 +134,11 @@ object CropMoneyDisplay { } if (InventoryUtils.itemInHandId.contains("DICER") && config.moneyPerHourDicer) { - var dicerDrops = 0.0 - val internalName: NEUInternalName - if (it == CropType.MELON) { - dicerDrops = GardenCropSpeed.latestMelonDicer - internalName = "ENCHANTED_MELON".asInternalName() - } else if (it == CropType.PUMPKIN) { - dicerDrops = GardenCropSpeed.latestPumpkinDicer - internalName = "ENCHANTED_PUMPKIN".asInternalName() - } else { - error("Impossible") + val (dicerDrops, internalName) = when (it) { + CropType.MELON -> GardenCropSpeed.latestMelonDicer to "ENCHANTED_MELON".asInternalName() + CropType.PUMPKIN -> GardenCropSpeed.latestPumpkinDicer to "ENCHANTED_PUMPKIN".asInternalName() + + else -> CopyErrorCommand.skyHanniError("Unknown dicer: $it") } val bazaarData = internalName.getBazaarData() val price = diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/CopyErrorCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/CopyErrorCommand.kt index 69288a896..946255996 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/CopyErrorCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/CopyErrorCommand.kt @@ -16,10 +16,15 @@ object CopyErrorCommand { private var cache = CacheBuilder.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES).build<Pair<String, Int>, Unit>() + fun skyHanniError(message: String): Nothing { + val exception = IllegalStateException(message) + logError(exception, message) + throw exception + } + fun command(array: Array<String>) { if (array.size != 1) { LorenzUtils.chat("§cUse /shcopyerror <error id>") - return } |