mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-29 16:15:17 +01:00
Fixed /randomenchant and added support for modifying vanilla conflictsWith behaviour
This commit is contained in:
parent
fcb7a45302
commit
d61169f29e
@ -1,5 +1,6 @@
|
||||
package com.willfp.ecoenchants.proxy.v1_16_R3.enchants;
|
||||
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.enchantments.support.vanilla.VanillaEnchantmentMetadata;
|
||||
import net.minecraft.server.v1_16_R3.Enchantment;
|
||||
import org.bukkit.NamespacedKey;
|
||||
@ -25,6 +26,11 @@ public class EcoCraftEnchantment extends CraftEnchantment {
|
||||
return metadata.getMaxLevel() == null ? this.getHandle().getMaxLevel() : metadata.getMaxLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean conflictsWith(@NotNull final org.bukkit.enchantments.Enchantment other) {
|
||||
return EcoEnchants.getFromEnchantment(other) == null ? super.conflictsWith(other) : other.conflictsWith(other);
|
||||
}
|
||||
|
||||
public void register() {
|
||||
try {
|
||||
Field byIdField = org.bukkit.enchantments.Enchantment.class.getDeclaredField("byKey");
|
||||
|
@ -80,6 +80,7 @@ public class CommandRandomenchant extends AbstractCommand {
|
||||
for (EcoEnchant ecoEnchant : ecoEnchants) {
|
||||
if (ecoEnchant.canEnchantItem(itemStack)) {
|
||||
if (!ecoEnchant.conflictsWithAny(onItem)) {
|
||||
if (ecoEnchant.isEnabled()) {
|
||||
if (onItem.stream().noneMatch(enchantment -> enchantment.conflictsWith(ecoEnchant))) {
|
||||
if (!onItem.contains(ecoEnchant)) {
|
||||
boolean conflicts = false;
|
||||
@ -104,6 +105,7 @@ public class CommandRandomenchant extends AbstractCommand {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (enchant == null) {
|
||||
player.sendMessage(this.getPlugin().getLangYml().getMessage("no-enchants-available"));
|
||||
|
Loading…
Reference in New Issue
Block a user