From 2703e2a471ecf6e732e330430663cc3421999afa Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Sun, 19 Mar 2023 20:47:37 +0100 Subject: Added a workaround to temporarily fix crashes when holding a hoe. Added debug information to fix this bug in the future for real --- .../at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt | 7 ++++++- .../skyhanni/features/garden/GardenCropMilestoneDisplay.kt | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni/features/garden') diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt index a0a58ffb2..893c65645 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/CropMoneyDisplay.kt @@ -108,7 +108,12 @@ class CropMoneyDisplay { for ((internalName, amount) in multipliers) { val price = NEUItems.getPrice(internalName) val cropName = cropNames[internalName]!! - val speed = GardenAPI.getCropsPerSecond(cropName)!! + val speed = GardenAPI.getCropsPerSecond(cropName) + if (speed == null) { + println("calculateMoneyPerHour: Speed is null for crop name '$cropName' ($internalName)") + LorenzUtils.debug("calculateMoneyPerHour: Speed is null!") + continue + } // No speed data for item in hand if (speed == -1) continue diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt index c4e8bf484..1faa8e3e7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneDisplay.kt @@ -82,7 +82,14 @@ class GardenCropMilestoneDisplay { if (cultivatingData.containsKey(crop)) { val old = cultivatingData[crop]!! val diff = counter - old - GardenCropMilestones.cropCounter[crop] = GardenCropMilestones.cropCounter[crop]!! + diff + try { + GardenCropMilestones.cropCounter[crop] = GardenCropMilestones.cropCounter[crop]!! + diff + } catch (e: NullPointerException) { + println("crop: '$crop'") + println("GardenCropMilestones.cropCounter: '${GardenCropMilestones.cropCounter.keys}'") + LorenzUtils.debug("NPE at OwnInventorItemUpdateEvent with GardenCropMilestones.cropCounter") + e.printStackTrace() + } EliteFarmingWeight.addCrop(crop, diff) if (currentCrop == crop) { calculateSpeed(diff) -- cgit