mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-24 00:26:16 +02:00
Make the singular type enchantment work as expected
This commit is contained in:
parent
3f6314ad09
commit
050d8bec8f
3 changed files with 24 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package com.willfp.ecoenchants.enchantments;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget;
|
||||
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
|
@ -19,4 +20,7 @@ public class EcoEnchant {
|
|||
return null;
|
||||
}
|
||||
|
||||
public EnchantmentType getType() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
package com.willfp.ecoenchants.enchantments.meta;
|
||||
|
||||
public class EnchantmentType {
|
||||
|
||||
public boolean isSingular() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ package xyz.alexcrea.cuanvil.enchant.wrapped;
|
|||
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget;
|
||||
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
|
@ -25,11 +26,21 @@ public class CALegacyEcoEnchant extends CABukkitEnchantment implements Additiona
|
|||
public boolean isEnchantConflict(@NotNull Map<CAEnchantment, Integer> enchantments, @NotNull Material itemMat) {
|
||||
if (enchantments.isEmpty()) return false;
|
||||
|
||||
EnchantmentType type = this.ecoEnchant.getType();
|
||||
boolean isSingular = type.isSingular();
|
||||
|
||||
for (CAEnchantment other : enchantments.keySet()) {
|
||||
if (other instanceof CABukkitEnchantment otherVanilla
|
||||
&& this.ecoEnchant.conflictsWith(otherVanilla.getEnchant())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isSingular &&
|
||||
other != this &&
|
||||
(other instanceof CALegacyEcoEnchant otherEco) &&
|
||||
type.equals(otherEco.ecoEnchant.getType())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue