diff --git a/Changelog.txt b/Changelog.txt index 9f85db54e..0b4b870d6 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,10 @@ +Version 2.2.011 + Improved logging for Alchemy potion look up (see notes) + +NOTES: + Added detailed logging when multiple configured potions match an ItemStack. + This will help identify issues with potion configuration. + Version 2.2.010 Fixed being unable to load REGEN potion type on new versions of Paper/Spigot 1.20.6 Fixed some potions not gaining XP when brewed (Level 2 potions, etc) diff --git a/pom.xml b/pom.xml index 8567d1d1b..7feea2206 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.2.010 + 2.2.011-SNAPSHOT mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/config/skills/alchemy/PotionConfig.java b/src/main/java/com/gmail/nossr50/config/skills/alchemy/PotionConfig.java index 5c9e023b7..626719921 100644 --- a/src/main/java/com/gmail/nossr50/config/skills/alchemy/PotionConfig.java +++ b/src/main/java/com/gmail/nossr50/config/skills/alchemy/PotionConfig.java @@ -342,7 +342,11 @@ public class PotionConfig extends LegacyConfigLoader { .filter(potion -> potion.isSimilarPotion(item)) .toList(); if(potionList.size() > 1) { - mcMMO.p.getLogger().severe("Multiple child potions matched for item, when there should only be one: " + item); + mcMMO.p.getLogger().severe("Multiple potions defined in config have match this potion, for mcMMO to behave" + + " properly there should only be one match found."); + mcMMO.p.getLogger().severe("Potion ItemStack:" + item.toString()); + mcMMO.p.getLogger().severe("Alchemy Potions from config matching this item: " + + potionList.stream().map(AlchemyPotion::toString).collect(Collectors.joining(", "))); } return potionList.isEmpty() ? null : potionList.get(0); diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/alchemy/AlchemyPotion.java b/src/main/java/com/gmail/nossr50/datatypes/skills/alchemy/AlchemyPotion.java index 51be1cde9..146894008 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/alchemy/AlchemyPotion.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/alchemy/AlchemyPotion.java @@ -19,11 +19,11 @@ public class AlchemyPotion { private final @NotNull ItemStack potionItemStack; private final @NotNull Map alchemyPotionChildren; - public AlchemyPotion(@NotNull String potionConfigName, @NotNull ItemStack potionItemStack, @NotNull Map alchemyPotionChildren) { + public AlchemyPotion(@NotNull String potionConfigName, @NotNull ItemStack potionItemStack, + @NotNull Map alchemyPotionChildren) { this.potionConfigName = requireNonNull(potionConfigName, "potionConfigName cannot be null"); this.potionItemStack = requireNonNull(potionItemStack, "potionItemStack cannot be null"); this.alchemyPotionChildren = requireNonNull(alchemyPotionChildren, "alchemyPotionChildren cannot be null"); - // mcMMO.p.getLogger().info("AlchemyPotion created: " + potionConfigName + ", with children: " + alchemyPotionChildren); } public @NotNull ItemStack toItemStack(int amount) { @@ -32,7 +32,7 @@ public class AlchemyPotion { return clone; } - public Map getAlchemyPotionChildren() { + public @NotNull Map getAlchemyPotionChildren() { return alchemyPotionChildren; } @@ -58,6 +58,10 @@ public class AlchemyPotion { return false; } + /* + * Compare custom effects on both potions. + */ + final PotionMeta otherPotionMeta = (PotionMeta) otherPotion.getItemMeta(); // compare custom effects on both potions, this has to be done in two traversals // comparing thisPotionMeta -> otherPotionMeta and otherPotionMeta -> thisPotionMeta @@ -70,17 +74,18 @@ public class AlchemyPotion { return false; } + /* + * If one potion has lore and the other does not, then they are not the same potion. + * If both have lore, compare the lore. + * If neither have lore, they may be the same potion. + */ if (!otherPotionMeta.hasLore() && getAlchemyPotionMeta().hasLore() || !getAlchemyPotionMeta().hasLore() && otherPotionMeta.hasLore()) { return false; } - if (otherPotionMeta.hasLore() && getAlchemyPotionMeta().hasLore() - && !otherPotionMeta.getLore().equals(getAlchemyPotionMeta().getLore())) { - return false; - } - - return true; + return !otherPotionMeta.hasLore() || !getAlchemyPotionMeta().hasLore() + || otherPotionMeta.getLore().equals(getAlchemyPotionMeta().getLore()); } private boolean hasDifferingCustomEffects(PotionMeta potionMeta, PotionMeta otherPotionMeta) {