From b20320d8fc9d0b8747dc955668226000a47e23cf Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Tue, 26 Sep 2023 10:46:09 +0200 Subject: code cleanup --- .../skyhanni/features/garden/FarmingFortuneDisplay.kt | 16 +++++++--------- .../itemabilities/abilitycooldown/ItemAbilityCooldown.kt | 3 ++- 2 files changed, 9 insertions(+), 10 deletions(-) (limited to 'src/main/java/at/hannibal2/skyhanni') diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt index 033fbb893..4776ff9c9 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt @@ -12,7 +12,6 @@ import at.hannibal2.skyhanni.features.garden.GardenAPI.getCropType import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName_old import at.hannibal2.skyhanni.utils.ItemUtils.getLore -import at.hannibal2.skyhanni.utils.ItemUtils.name import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.addAsSingletonList import at.hannibal2.skyhanni.utils.NEUInternalName @@ -207,16 +206,15 @@ class FarmingFortuneDisplay { return dedicationMultiplier * cropMilestone } - fun getSunderFortune(tool: ItemStack?): Double { return (tool?.getEnchantments()?.get("sunder") ?: 0) * 12.5 } - fun getHarvestingFortune(tool: ItemStack?): Double { return (tool?.getEnchantments()?.get("harvesting") ?: 0) * 12.5 } - fun getCultivatingFortune(tool: ItemStack?): Double { return (tool?.getEnchantments()?.get("cultivating") ?: 0) * 2.0} + fun getSunderFortune(tool: ItemStack?) = (tool?.getEnchantments()?.get("sunder") ?: 0) * 12.5 + fun getHarvestingFortune(tool: ItemStack?) = (tool?.getEnchantments()?.get("harvesting") ?: 0) * 12.5 + fun getCultivatingFortune(tool: ItemStack?) = (tool?.getEnchantments()?.get("cultivating") ?: 0) * 2.0 - fun getAbilityFortune(item: ItemStack?): Double { - if (item == null) return 0.0 - return getAbilityFortune(item.getInternalName(), item.getLore()) - } + fun getAbilityFortune(item: ItemStack?) = item?.let { + getAbilityFortune(it.getInternalName(), it.getLore()) + } ?: 0.0 - fun getAbilityFortune(internalName: NEUInternalName, lore: List): Double { + fun getAbilityFortune(internalName: NEUInternalName, lore: List): Double { val lotusAbilityPattern = "§7Piece Bonus: §6+(?.*)☘".toPattern() // todo make it work on Melon and Cropie armor val armorAbilityFortune = "§7.*§7Grants §6(?.*)☘.*".toPattern() diff --git a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt index 7aca21152..8f9a58c24 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/itemabilities/abilitycooldown/ItemAbilityCooldown.kt @@ -285,7 +285,8 @@ class ItemAbilityCooldown { val stack = event.stack val guiOpen = Minecraft.getMinecraft().currentScreen != null - val list = items.filter { it.key.getItemUuid() == stack.getItemUuid() } + val uuid = stack.getItemUuid() + val list = items.filter { it.key.getItemUuid() == uuid } .firstNotNullOfOrNull { it.value } ?: return for (itemText in list) { -- cgit