parent
4c38eeb683
commit
79a820efc1
@ -8,12 +8,11 @@ import nl.pim16aap2.armoredElytra.util.Util;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings({"unused", "UnusedReturnValue", "ClassCanBeRecord"})
|
||||
public class ArmoredElytraBuilder
|
||||
@ -72,15 +71,7 @@ public class ArmoredElytraBuilder
|
||||
final EnchantmentContainer enchantments = EnchantmentContainer.getEnchantments(sourceItem, plugin);
|
||||
if (enchantments.isEmpty())
|
||||
return null;
|
||||
// Check for mutually exclusive enchantments
|
||||
final Map<Enchantment, Integer> updatedEnchantments = new LinkedHashMap<>();
|
||||
enchantments.forEach(enchantment -> updatedEnchantments.put(enchantment.getKey(), enchantment.getValue()));
|
||||
for (Map.Entry<Enchantment, Integer> elytraEnchantment : EnchantmentContainer.getEnchantments(armoredElytra, plugin))
|
||||
updatedEnchantments.keySet().removeIf(sourceEnchantment -> EnchantmentContainer.areMutuallyExclusive(sourceEnchantment, elytraEnchantment.getKey()));
|
||||
if (updatedEnchantments.isEmpty())
|
||||
return null;
|
||||
|
||||
return newBuilder().ofElytra(armoredElytra).addEnchantments(new EnchantmentContainer(updatedEnchantments, plugin)).withName(name).build();
|
||||
return newBuilder().ofElytra(armoredElytra).addEnchantments(enchantments).withName(name).build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user