mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
Add comment and Finish test of conflict for CAEnchant.
This commit is contained in:
parent
dafe595c5b
commit
3c60e157e4
5 changed files with 71 additions and 23 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package xyz.alexcrea.cuanvil.enchant;
|
||||
|
||||
import io.delilaheve.util.ItemUtil;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
|
@ -16,7 +17,7 @@ import xyz.alexcrea.cuanvil.group.EnchantConflictGroup;
|
|||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* Represent an enchantment compatible with Custom Anvil.
|
||||
|
|
@ -65,14 +66,40 @@ public interface CAEnchantment {
|
|||
*/
|
||||
boolean isAllowed(@NotNull HumanEntity player);
|
||||
|
||||
/**
|
||||
* Add a conflict to this enchantment conflict list.
|
||||
* @param conflict The conflict to add.
|
||||
*/
|
||||
void addConflict(@NotNull EnchantConflictGroup conflict);
|
||||
|
||||
/**
|
||||
* Remove a conflict from the conflict list of this enchantment.
|
||||
* @param conflict The conflict to remove from this enchantment.
|
||||
*/
|
||||
void removeConflict(@NotNull EnchantConflictGroup conflict);
|
||||
|
||||
/**
|
||||
* Clear Custom Anvil conflicts for this enchantment.
|
||||
*/
|
||||
void clearConflict();
|
||||
|
||||
@NotNull Set<EnchantConflictGroup> getConflicts();
|
||||
/**
|
||||
* Get a collection of Custom Anvil conflict containing this enchantment.
|
||||
* @return A collection of Custom Anvil conflict containing this enchantment.
|
||||
*/
|
||||
@NotNull Collection<EnchantConflictGroup> getConflicts();
|
||||
|
||||
@NotNull ConflictType testConflict();
|
||||
/**
|
||||
* Test if the provided item can be compatible with this
|
||||
* @param baseEnchantments Validated enchantments for the item.
|
||||
* @param itemMat Material of the tested item.
|
||||
* @param itemSupply Provide a new instance of used item stack but with baseEnchantments as enchantments.
|
||||
* @return Type of conflict this enchantment has with the provided item.
|
||||
*/
|
||||
@NotNull
|
||||
ConflictType testConflict(@NotNull Map<CAEnchantment, Integer> baseEnchantments,
|
||||
@NotNull Material itemMat,
|
||||
@NotNull Supplier<ItemStack> itemSupply);
|
||||
|
||||
/**
|
||||
* Get current level of the enchantment.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package xyz.alexcrea.cuanvil.enchant;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
|
@ -9,8 +10,11 @@ import org.jetbrains.annotations.Nullable;
|
|||
import xyz.alexcrea.cuanvil.group.ConflictType;
|
||||
import xyz.alexcrea.cuanvil.group.EnchantConflictGroup;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public abstract class CAEnchantmentBase implements CAEnchantment {
|
||||
|
||||
|
|
@ -22,7 +26,7 @@ public abstract class CAEnchantmentBase implements CAEnchantment {
|
|||
private final EnchantmentRarity defaultRarity;
|
||||
private final int defaultMaxLevel;
|
||||
|
||||
private final Set<EnchantConflictGroup> conflicts;
|
||||
private final List<EnchantConflictGroup> conflicts;
|
||||
|
||||
/**
|
||||
* Constructor of Wrapped Enchantment.
|
||||
|
|
@ -38,10 +42,9 @@ public abstract class CAEnchantmentBase implements CAEnchantment {
|
|||
this.name = key.getKey();
|
||||
this.defaultMaxLevel = defaultMaxLevel;
|
||||
|
||||
if(defaultRarity == null) this.defaultRarity = EnchantmentRarity.COMMON;
|
||||
else this.defaultRarity = defaultRarity;
|
||||
this.defaultRarity = Objects.requireNonNullElse(defaultRarity, EnchantmentRarity.COMMON);
|
||||
|
||||
this.conflicts = new HashSet<>();
|
||||
this.conflicts = new ArrayList<>();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
|
@ -105,12 +108,14 @@ public abstract class CAEnchantmentBase implements CAEnchantment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Set<EnchantConflictGroup> getConflicts() {
|
||||
public @NotNull List<EnchantConflictGroup> getConflicts() {
|
||||
return conflicts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull ConflictType testConflict() {
|
||||
public @NotNull ConflictType testConflict(@NotNull Map<CAEnchantment, Integer> baseEnchantments,
|
||||
@NotNull Material itemMat,
|
||||
@NotNull Supplier<ItemStack> itemSupply) {
|
||||
return ConflictType.NO_CONFLICT;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue