Check if the item has item meta and, if it doesn't, bail out

This commit is contained in:
MrPowerGamerBR 2024-08-25 18:05:48 -03:00
parent 595c43e34e
commit 52ee5f4843

View File

@ -335,6 +335,10 @@ public class PotionConfig extends LegacyConfigLoader {
* @return AlchemyPotion that corresponds to the given ItemStack.
*/
public AlchemyPotion getPotion(ItemStack item) {
// Fast return if the item does not have any item meta to avoid initializing an unnecessary ItemMeta instance
if (!item.hasItemMeta())
return null;
ItemMeta itemMeta = item.getItemMeta();
final List<AlchemyPotion> potionList = alchemyPotions.values()
.stream()