aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features/garden
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-04-19 23:47:02 +0200
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-04-19 23:47:02 +0200
commit1e52428d3939d0b579cbc156b4e30fb4e8cdc342 (patch)
tree0a2aa3b81a5034654a7a135975d830606eb79641 /src/main/java/at/hannibal2/skyhanni/features/garden
parent50dfb62bad66e9bdb04cca17a2dd32a69b108265 (diff)
downloadskyhanni-1e52428d3939d0b579cbc156b4e30fb4e8cdc342.tar.gz
skyhanni-1e52428d3939d0b579cbc156b4e30fb4e8cdc342.tar.bz2
skyhanni-1e52428d3939d0b579cbc156b4e30fb4e8cdc342.zip
Code cleanup
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/garden')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt7
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropCounter.kt2
4 files changed, 6 insertions, 7 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 c8888b688..df86b08d1 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/CropType.kt
@@ -33,17 +33,16 @@ enum class CropType(
val multiplier by lazy { if (this == SUGAR_CANE || this == CACTUS) 2 else 1 }
companion object {
- fun getByName(cropName: String) = values().firstOrNull { it.cropName == cropName }
+ fun getByNameOrNull(cropName: String) = values().firstOrNull { it.cropName == cropName }
- // TODO find better name for this method
- fun getByNameNoNull(name: String) = getByName(name) ?: throw RuntimeException("No valid crop type '$name'")
+ fun getByName(name: String) = getByNameOrNull(name) ?: throw RuntimeException("No valid crop type '$name'")
fun getByItemName(itemName: String): CropType? {
if (itemName == "Red Mushroom" || itemName == "Brown Mushroom") return MUSHROOM
if (itemName == "Seeds") return WHEAT
- return getByName(itemName)
+ return getByNameOrNull(itemName)
}
fun IBlockState.getCropType(): CropType? {
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt
index 33a605379..c42ab8d6f 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenCropMilestoneFix.kt
@@ -35,7 +35,7 @@ class GardenCropMilestoneFix {
val progress = progressCrops * (percentage / 100)
val smallestPercentage = progressCrops * 0.0005
- val crop = CropType.getByName(cropName)
+ val crop = CropType.getByNameOrNull(cropName)
if (crop == null) {
LorenzUtils.debug("GardenCropMilestoneFix: crop is null: '$cropName'")
return
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
index c5c5d6978..1037d0bb3 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/GardenNextJacobContest.kt
@@ -118,7 +118,7 @@ class GardenNextJacobContest {
for (line in lore) {
val matcherCrop = patternCrop.matcher(line)
if (!matcherCrop.matches()) continue
- crops.add(CropType.getByNameNoNull(matcherCrop.group(1)))
+ crops.add(CropType.getByName(matcherCrop.group(1)))
}
val contest = FarmingContest(startTime + contestDuration, crops)
contests[startTime] = contest
diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropCounter.kt
index c190217bb..ca15c038a 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropCounter.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/garden/farming/DicerRngDropCounter.kt
@@ -118,7 +118,7 @@ class DicerRngDropCounter {
fun onConfigLoad(event: ConfigLoadEvent) {
for ((internalName, amount) in SkyHanniMod.feature.hidden.gardenDicerRngDrops) {
val split = internalName.split(".")
- val crop = CropType.getByNameNoNull(split[0])
+ val crop = CropType.getByName(split[0])
val rarityName = split[1]
val rarity = DropRarity.valueOf(rarityName)
drops[crop]!![rarity] = amount