mirror of
				https://github.com/mcMMO-Dev/mcMMO.git
				synced 2025-11-03 18:43:43 +01:00 
			
		
		
		
	more verbose logging for alchemy potion lookups
This commit is contained in:
		@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -19,11 +19,11 @@ public class AlchemyPotion {
 | 
			
		||||
    private final @NotNull ItemStack potionItemStack;
 | 
			
		||||
    private final @NotNull Map<ItemStack, String> alchemyPotionChildren;
 | 
			
		||||
 | 
			
		||||
    public AlchemyPotion(@NotNull String potionConfigName, @NotNull ItemStack potionItemStack, @NotNull Map<ItemStack, String> alchemyPotionChildren) {
 | 
			
		||||
    public AlchemyPotion(@NotNull String potionConfigName, @NotNull ItemStack potionItemStack,
 | 
			
		||||
                         @NotNull Map<ItemStack, String> 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<ItemStack, String> getAlchemyPotionChildren() {
 | 
			
		||||
    public @NotNull Map<ItemStack, String> 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) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user