From 82a1bca332a650b2b6553d6382d4668dfe8f45a5 Mon Sep 17 00:00:00 2001 From: CalMWolfs <94038482+CalMWolfs@users.noreply.github.com> Date: Thu, 26 Oct 2023 17:47:10 +1100 Subject: fix future neu crash (#624) Fixed potential crash with future neu version. #624 --- .../skyhanni/features/bazaar/BazaarOpenPriceWebsite.kt | 4 ++-- .../skyhanni/features/garden/composter/ComposterDisplay.kt | 8 ++++---- .../skyhanni/features/garden/farming/CropMoneyDisplay.kt | 4 ++-- .../features/garden/fortuneguide/pages/UpgradePage.kt | 4 ++-- .../skyhanni/features/garden/inventory/GardenDeskInSBMenu.kt | 4 ++-- .../skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt | 2 +- src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt | 12 ++++-------- 7 files changed, 17 insertions(+), 21 deletions(-) diff --git a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarOpenPriceWebsite.kt b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarOpenPriceWebsite.kt index b39809125..74922ebe4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarOpenPriceWebsite.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/bazaar/BazaarOpenPriceWebsite.kt @@ -18,7 +18,7 @@ class BazaarOpenPriceWebsite { private var lastClick = SimpleTimeMark.farPast() private val item by lazy { - val neuItem = NEUItems.getItemStack("PAPER", true) + val neuItem = NEUItems.getItemStack("PAPER") Utils.createItemStack( neuItem.item, "§bPrice History", @@ -62,4 +62,4 @@ class BazaarOpenPriceWebsite { } fun isEnabled() = config.openPriceWebsite -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt index 553d0cea0..5139d8a95 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/composter/ComposterDisplay.kt @@ -33,7 +33,7 @@ class ComposterDisplay { STORED_COMPOST(" Stored Compost: §r(.*)", "COMPOST"); val displayItem by lazy { - NEUItems.getItemStack(icon, true) + NEUItems.getItemStack(icon) } val pattern by lazy { rawPattern.toPattern() } @@ -102,7 +102,7 @@ class ComposterDisplay { val millis = emptyTime.toDouble(DurationUnit.MILLISECONDS).toLong() GardenAPI.config?.composterEmptyTime = System.currentTimeMillis() + millis val format = TimeUtils.formatDuration(millis, maxUnits = 2) - listOf(NEUItems.getItemStack("BUCKET", true), "§b$format") + listOf(NEUItems.getItemStack("BUCKET"), "§b$format") } else { listOf("§cOpen Composter Upgrades!") } @@ -188,7 +188,7 @@ class ComposterDisplay { } else "?" if (!GardenAPI.inGarden() && config.displayOutsideGarden) { - val list = Collections.singletonList(listOf(NEUItems.getItemStack("BUCKET", true), "§b$format")) + val list = Collections.singletonList(listOf(NEUItems.getItemStack("BUCKET"), "§b$format")) config.outsideGardenPos.renderStringsAndItems(list, posLabel = "Composter Outside Garden Display") } } @@ -219,4 +219,4 @@ class ComposterDisplay { event.move(3, "garden.composterNotifyLowOrganicMatter", "garden.composters.notifyLow.organicMatter") event.move(3, "garden.composterNotifyLowFuel", "garden.composters.notifyLow.fuel") } -} \ No newline at end of file +} 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 cf649b9be..ff65011c6 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 @@ -193,13 +193,13 @@ object CropMoneyDisplay { try { if (isSeeds(internalName)) { - list.add(getItemStack("BOX_OF_SEEDS", true)) + list.add(getItemStack("BOX_OF_SEEDS")) } else { list.add(internalName.getItemStack()) } if (cropNames[internalName] == CropType.WHEAT && config.mergeSeeds) { - list.add(getItemStack("BOX_OF_SEEDS", true)) + list.add(getItemStack("BOX_OF_SEEDS")) } } catch (e: NullPointerException) { e.printStackTrace() diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/UpgradePage.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/UpgradePage.kt index bef201bc7..6076efd21 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/UpgradePage.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/fortuneguide/pages/UpgradePage.kt @@ -33,7 +33,7 @@ class UpgradePage: FFGuideGUI.FFGuidePage() { for ((index, upgrade) in upgradeList.withIndex()) { if (adjustedY + 25 * index < FFGuideGUI.guiTop + 20) continue if (adjustedY + 25 * index > FFGuideGUI.guiTop + 160) continue - val upgradeItem = upgrade.requiredItem.let { NEUItems.getItemStack(it, true) } + val upgradeItem = upgrade.requiredItem.let { NEUItems.getItemStack(it) } var formattedUpgrade = upgradeItem.nameWithEnchantment ?: return if (adjustedY + 25 * index - 5 < FFGuideGUI.lastClickedHeight && FFGuideGUI.lastClickedHeight < adjustedY + 25 * index + 10) { FFGuideGUI.lastClickedHeight = 0 @@ -72,4 +72,4 @@ class UpgradePage: FFGuideGUI.FFGuidePage() { pageScroll = MathHelper.clamp_int(pageScroll, -(listLength * 15 - 15), 0) FFGuideGUI.lastMouseScroll = 0 } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenDeskInSBMenu.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenDeskInSBMenu.kt index cc48a01f1..a3f72ac4c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenDeskInSBMenu.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/inventory/GardenDeskInSBMenu.kt @@ -19,7 +19,7 @@ class GardenDeskInSBMenu { private var showItem = false private val item by lazy { - val neuItem = NEUItems.getItemStack("DOUBLE_PLANT", true) + val neuItem = NEUItems.getItemStack("DOUBLE_PLANT") Utils.createItemStack(neuItem.item, "§bDesk", "§7Click here to", "§7run §e/desk") } @@ -47,4 +47,4 @@ class GardenDeskInSBMenu { LorenzUtils.sendCommandToServer("desk") } } -} \ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt index e58215a68..de2b117d4 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/EnigmaSoulWaypoints.kt @@ -36,7 +36,7 @@ object EnigmaSoulWaypoints { private var adding = true private val item by lazy { - val neuItem = NEUItems.getItemStack("SKYBLOCK_ENIGMA_SOUL", true) + val neuItem = NEUItems.getItemStack("SKYBLOCK_ENIGMA_SOUL") Utils.createItemStack( neuItem.item, "§5Toggle Missing", diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt index fdbe8c995..f73fbcdb4 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt @@ -172,16 +172,12 @@ object NEUItems { fun getItemStackOrNull(internalName: String) = internalName.asInternalName().getItemStackOrNull() // TODO remove - fun getItemStack(internalName: String, definite: Boolean = false): ItemStack = - internalName.asInternalName().getItemStack(definite) + fun getItemStack(internalName: String): ItemStack = + internalName.asInternalName().getItemStack() - fun NEUInternalName.getItemStack(definite: Boolean = false): ItemStack = + fun NEUInternalName.getItemStack(): ItemStack = getItemStackOrNull() ?: run { if (getPriceOrNull() == null) return@run fallbackItem - - if (definite) { - Utils.showOutdatedRepoNotification() - } ErrorManager.logError( IllegalStateException("Something went wrong!"), "Encountered an error getting the item for §7$this§c. " + @@ -330,4 +326,4 @@ object NEUItems { val jsonObject = ConfigManager.gson.fromJson(jsonString, JsonObject::class.java) return manager.jsonToStack(jsonObject, false) } -} \ No newline at end of file +} -- cgit