mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
Fix type limit not existing for modern eco enchant
This commit is contained in:
parent
343f57fdc7
commit
85d2d873eb
1 changed files with 22 additions and 5 deletions
|
|
@ -2,6 +2,7 @@ package xyz.alexcrea.cuanvil.enchant.wrapped;
|
|||
|
||||
import com.willfp.ecoenchants.enchant.EcoEnchant;
|
||||
import com.willfp.ecoenchants.target.EnchantmentTarget;
|
||||
import com.willfp.ecoenchants.type.EnchantmentType;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
|
@ -9,6 +10,7 @@ import xyz.alexcrea.cuanvil.enchant.AdditionalTestEnchantment;
|
|||
import xyz.alexcrea.cuanvil.enchant.CAEnchantment;
|
||||
import xyz.alexcrea.cuanvil.enchant.EnchantmentRarity;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class CAEcoEnchant extends CABukkitEnchantment implements AdditionalTestEnchantment {
|
||||
|
|
@ -22,17 +24,32 @@ public class CAEcoEnchant extends CABukkitEnchantment implements AdditionalTestE
|
|||
|
||||
@Override
|
||||
public boolean isEnchantConflict(@NotNull Map<CAEnchantment, Integer> enchantments, @NotNull Material itemMat) {
|
||||
if(enchantments.isEmpty()) return false;
|
||||
if (enchantments.isEmpty()) return false;
|
||||
|
||||
if (this.ecoEnchant.getConflictsWithEverything()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
HashMap<EnchantmentType, Integer> typeAmountMap = new HashMap<>();
|
||||
|
||||
for (CAEnchantment other : enchantments.keySet()) {
|
||||
if(other instanceof CABukkitEnchantment otherVanilla
|
||||
&& this.ecoEnchant.conflictsWith(otherVanilla.getEnchant())){
|
||||
if (other instanceof CABukkitEnchantment otherVanilla
|
||||
&& this.ecoEnchant.conflictsWith(otherVanilla.getEnchant())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (other instanceof CAEcoEnchant ecoOther) {
|
||||
EnchantmentType type = ecoOther.ecoEnchant.getType();
|
||||
typeAmountMap.putIfAbsent(type, 0);
|
||||
|
||||
int amount = typeAmountMap.get(type) + 1;
|
||||
if (amount > type.getLimit()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
typeAmountMap.put(type, amount);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -42,12 +59,12 @@ public class CAEcoEnchant extends CABukkitEnchantment implements AdditionalTestE
|
|||
public boolean isItemConflict(@NotNull Map<CAEnchantment, Integer> enchantments,
|
||||
@NotNull Material itemMat,
|
||||
@NotNull ItemStack item) {
|
||||
if(Material.ENCHANTED_BOOK.equals(itemMat)){
|
||||
if (Material.ENCHANTED_BOOK.equals(itemMat)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (EnchantmentTarget target : this.ecoEnchant.getTargets()) {
|
||||
if(target.matches(item)){
|
||||
if (target.matches(item)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue