mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-26 15:45:12 +01:00
Added flags
This commit is contained in:
parent
ca8169d46b
commit
c00834fd62
@ -142,6 +142,11 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Watche
|
||||
@Getter
|
||||
private boolean enabled;
|
||||
|
||||
/**
|
||||
* Custom option flags for the enchantment.
|
||||
*/
|
||||
private final List<String> flags = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Create a new EcoEnchant.
|
||||
*
|
||||
@ -215,6 +220,8 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Watche
|
||||
targets.addAll(config.getTargets());
|
||||
targets.forEach(enchantmentTarget -> targetMaterials.addAll(enchantmentTarget.getMaterials()));
|
||||
enabled = config.getBool("enabled");
|
||||
flags.clear();
|
||||
flags.addAll(config.getStrings(EcoEnchants.GENERAL_LOCATION + "flags"));
|
||||
EnchantmentUtils.registerPlaceholders(this);
|
||||
|
||||
postUpdate();
|
||||
@ -253,12 +260,13 @@ public abstract class EcoEnchant extends Enchantment implements Listener, Watche
|
||||
}
|
||||
|
||||
/**
|
||||
* Get enchantment cast to {@link Enchantment}.
|
||||
* If enchantment has specified flag.
|
||||
*
|
||||
* @return The enchantment.
|
||||
* @param flag The flag.
|
||||
* @return If the enchantment has the flag.
|
||||
*/
|
||||
public Enchantment getEnchantment() {
|
||||
return this;
|
||||
public boolean hasFlag(@NotNull final String flag) {
|
||||
return this.flags.contains(flag);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -144,7 +144,15 @@ public class AnvilMerge {
|
||||
|
||||
if (PLUGIN.getConfigYml().getBool("anvil.hard-cap.enabled")) {
|
||||
if (!player.hasPermission("ecoenchants.anvil.bypasshardcap")) {
|
||||
if (outEnchants.size() >= PLUGIN.getConfigYml().getInt("anvil.hard-cap.cap")) {
|
||||
if (outEnchants.keySet()
|
||||
.stream()
|
||||
.filter(enchant -> {
|
||||
if (enchant instanceof EcoEnchant) {
|
||||
return !((EcoEnchant) enchant).hasFlag("hard-cap-ignore");
|
||||
}
|
||||
|
||||
return true;
|
||||
}).count() >= PLUGIN.getConfigYml().getInt("anvil.hard-cap.cap")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -182,7 +190,15 @@ public class AnvilMerge {
|
||||
|
||||
if (PLUGIN.getConfigYml().getBool("anvil.hard-cap.enabled")) {
|
||||
if (!player.hasPermission("ecoenchants.anvil.bypasshardcap")) {
|
||||
if (outEnchants.size() >= PLUGIN.getConfigYml().getInt("anvil.hard-cap.cap")) {
|
||||
if (outEnchants.keySet()
|
||||
.stream()
|
||||
.filter(enchant -> {
|
||||
if (enchant instanceof EcoEnchant) {
|
||||
return !((EcoEnchant) enchant).hasFlag("hard-cap-ignore");
|
||||
}
|
||||
|
||||
return true;
|
||||
}).count() >= PLUGIN.getConfigYml().getInt("anvil.hard-cap.cap")) {
|
||||
doesConflict.set(true);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user