From 7628c0bbfd4f1c099cee25c73ed38b5f9de35c8e Mon Sep 17 00:00:00 2001 From: Auxilor Date: Thu, 3 Feb 2022 11:17:29 +0000 Subject: [PATCH] Renamed FastItemStack methods --- .../willfp/eco/core/fast/FastItemStack.java | 24 ++++++++++++++++++- .../internal/items/ArgParserEnchantment.kt | 2 +- .../proxy/v1_16_R3/fast/NMSFastItemStack.kt | 2 +- .../proxy/v1_17_R1/fast/NMSFastItemStack.kt | 2 +- .../proxy/v1_18_R1/fast/NMSFastItemStack.kt | 2 +- 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/eco-api/src/main/java/com/willfp/eco/core/fast/FastItemStack.java b/eco-api/src/main/java/com/willfp/eco/core/fast/FastItemStack.java index 63afa1d1..5eac88dc 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/fast/FastItemStack.java +++ b/eco-api/src/main/java/com/willfp/eco/core/fast/FastItemStack.java @@ -22,8 +22,30 @@ public interface FastItemStack { * * @param checkStored If stored NBT should also be checked. * @return A map of all enchantments. + * @deprecated Poorly named method. Use {@link this#getEnchants(boolean)} instead. */ - Map getEnchantmentsOnItem(boolean checkStored); + @Deprecated + default Map getEnchantmentsOnItem(boolean checkStored) { + return getEnchants(checkStored); + } + + /** + * Get all enchantments on an item. + * Does not account for stored enchants. + * + * @return A map of all enchantments. + */ + default Map getEnchants() { + return getEnchants(false); + } + + /** + * Get all enchantments on an item. + * + * @param checkStored If stored enchantments should be accounted for. + * @return A map of all enchantments. + */ + Map getEnchants(boolean checkStored); /** * Get the level of an enchantment on an item. diff --git a/eco-core/core-backend/src/main/kotlin/com/willfp/eco/internal/items/ArgParserEnchantment.kt b/eco-core/core-backend/src/main/kotlin/com/willfp/eco/internal/items/ArgParserEnchantment.kt index fa2ae9e6..22a61fe6 100644 --- a/eco-core/core-backend/src/main/kotlin/com/willfp/eco/internal/items/ArgParserEnchantment.kt +++ b/eco-core/core-backend/src/main/kotlin/com/willfp/eco/internal/items/ArgParserEnchantment.kt @@ -41,7 +41,7 @@ class ArgParserEnchantment : LookupArgParser { } return Predicate { - val onItem = it.fast().getEnchantmentsOnItem(true) + val onItem = it.fast().getEnchants(true) for ((enchant, level) in enchants) { if ((onItem[enchant] ?: 0) < level) { diff --git a/eco-core/core-nms/v1_16_R3/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_16_R3/fast/NMSFastItemStack.kt b/eco-core/core-nms/v1_16_R3/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_16_R3/fast/NMSFastItemStack.kt index ebec7524..951d6dfc 100644 --- a/eco-core/core-nms/v1_16_R3/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_16_R3/fast/NMSFastItemStack.kt +++ b/eco-core/core-nms/v1_16_R3/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_16_R3/fast/NMSFastItemStack.kt @@ -20,7 +20,7 @@ class NMSFastItemStack(itemStack: org.bukkit.inventory.ItemStack) : EcoFastItemS itemStack.getNMSStack(), itemStack ) { private var loreCache: List? = null - override fun getEnchantmentsOnItem(checkStored: Boolean): Map { + override fun getEnchants(checkStored: Boolean): Map { val enchantmentNBT = if (checkStored && handle.item === Items.ENCHANTED_BOOK) ItemEnchantedBook.d( handle ) else handle.enchantments diff --git a/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_17_R1/fast/NMSFastItemStack.kt b/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_17_R1/fast/NMSFastItemStack.kt index 403156e8..bc9943f9 100644 --- a/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_17_R1/fast/NMSFastItemStack.kt +++ b/eco-core/core-nms/v1_17_R1/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_17_R1/fast/NMSFastItemStack.kt @@ -21,7 +21,7 @@ class NMSFastItemStack(itemStack: org.bukkit.inventory.ItemStack) : EcoFastItemS ) { private var loreCache: List? = null - override fun getEnchantmentsOnItem(checkStored: Boolean): Map { + override fun getEnchants(checkStored: Boolean): Map { val enchantmentNBT = if (checkStored && handle.item === Items.ENCHANTED_BOOK) EnchantedBookItem.getEnchantments( handle diff --git a/eco-core/core-nms/v1_18_R1/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_18_R1/fast/NMSFastItemStack.kt b/eco-core/core-nms/v1_18_R1/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_18_R1/fast/NMSFastItemStack.kt index 659058af..56f749e0 100644 --- a/eco-core/core-nms/v1_18_R1/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_18_R1/fast/NMSFastItemStack.kt +++ b/eco-core/core-nms/v1_18_R1/src/main/kotlin/com/willfp/eco/internal/spigot/proxy/v1_18_R1/fast/NMSFastItemStack.kt @@ -22,7 +22,7 @@ class NMSFastItemStack(itemStack: org.bukkit.inventory.ItemStack) : EcoFastItemS ) { private var loreCache: List? = null - override fun getEnchantmentsOnItem(checkStored: Boolean): Map { + override fun getEnchants(checkStored: Boolean): Map { val enchantmentNBT = if (checkStored && handle.getItem() === Items.ENCHANTED_BOOK) EnchantedBookItem.getEnchantments( handle