mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
Rework the conflict system to be mostly handled by the enchantment.
This commit is contained in:
parent
b7fda4dece
commit
fa4752ea67
4 changed files with 69 additions and 28 deletions
|
|
@ -13,6 +13,9 @@ import org.jetbrains.annotations.Nullable;
|
|||
import xyz.alexcrea.cuanvil.dependency.DependencyManager;
|
||||
import xyz.alexcrea.cuanvil.dependency.EnchantmentSquaredDependency;
|
||||
import xyz.alexcrea.cuanvil.enchant.wrapped.VanillaEnchantment;
|
||||
import xyz.alexcrea.cuanvil.group.AbstractMaterialGroup;
|
||||
import xyz.alexcrea.cuanvil.group.ConflictType;
|
||||
import xyz.alexcrea.cuanvil.group.EnchantConflictGroup;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
|
@ -31,6 +34,8 @@ public abstract class WrappedEnchantment {
|
|||
private final EnchantmentRarity defaultRarity;
|
||||
private final int defaultMaxLevel;
|
||||
|
||||
private final Set<EnchantConflictGroup> conflicts;
|
||||
|
||||
/**
|
||||
* Constructor of Wrapped Enchantment.
|
||||
* @param key The enchantment's key.
|
||||
|
|
@ -47,6 +52,8 @@ public abstract class WrappedEnchantment {
|
|||
|
||||
if(defaultRarity == null) this.defaultRarity = EnchantmentRarity.COMMON;
|
||||
else this.defaultRarity = defaultRarity;
|
||||
|
||||
this.conflicts = new HashSet<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -109,6 +116,25 @@ public abstract class WrappedEnchantment {
|
|||
return getLevel(item, meta);
|
||||
}
|
||||
|
||||
public void addConflict(@NotNull EnchantConflictGroup conflict){
|
||||
this.conflicts.add(conflict);
|
||||
}
|
||||
public void removeConflict(@NotNull EnchantConflictGroup conflict){
|
||||
this.conflicts.remove(conflict);
|
||||
}
|
||||
|
||||
public void clearConflict(){
|
||||
this.conflicts.clear();
|
||||
}
|
||||
|
||||
public @NotNull Set<EnchantConflictGroup> getConflicts() {
|
||||
return conflicts;
|
||||
}
|
||||
|
||||
public @NotNull ConflictType testConflict() {
|
||||
return ConflictType.NO_CONFLICT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current level of the enchantment.
|
||||
* @param item Item to search the level for.
|
||||
|
|
|
|||
|
|
@ -117,9 +117,9 @@ public class EnchantConflictSubSettingGui extends MappedToListSubSettingGui impl
|
|||
Supplier<Boolean> deleteSupplier = () -> {
|
||||
EnchantConflictManager manager = ConfigHolder.CONFLICT_HOLDER.getConflictManager();
|
||||
|
||||
// Remove from manager
|
||||
// Remove from enchantment
|
||||
for (WrappedEnchantment enchantment : this.enchantConflict.getEnchants()) {
|
||||
manager.removeConflictFromMap(enchantment, this.enchantConflict);
|
||||
enchantment.removeConflict(this.enchantConflict);
|
||||
}
|
||||
manager.conflictList.remove(this.enchantConflict);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue