diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BlockDropEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BlockDropEnchant.java index 777145d..ea44355 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BlockDropEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/api/enchantment/type/BlockDropEnchant.java @@ -9,6 +9,6 @@ import su.nightexpress.excellentenchants.api.enchantment.IEnchantment; public interface BlockDropEnchant extends IEnchantment { - boolean onDrop(@NotNull BlockDropItemEvent e, @NotNull EnchantDropContainer dropContainer, + boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level); } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java index e2ba0ba..4ed5b3e 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/EnchantRegistry.java @@ -4,6 +4,7 @@ import org.bukkit.NamespacedKey; import org.bukkit.enchantments.Enchantment; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import su.nexmedia.engine.Version; import su.nexmedia.engine.utils.Reflex; import su.nightexpress.excellentenchants.ExcellentEnchants; import su.nightexpress.excellentenchants.config.Config; @@ -123,6 +124,11 @@ public class EnchantRegistry { this.register(EnchantPoisonedArrows.ID, () -> new EnchantPoisonedArrows(plugin)); this.register(EnchantWitheredArrows.ID, () -> new EnchantWitheredArrows(plugin)); + if (Version.isAbove(Version.V1_18_R2)) { + this.register(DarknessArrowsEnchant.ID, () -> new DarknessArrowsEnchant(plugin)); + this.register(DarknessCloakEnchant.ID, () -> new DarknessCloakEnchant(plugin)); + } + // Universal this.register(EnchantCurseOfFragility.ID, () -> new EnchantCurseOfFragility(plugin)); this.register(CurseOfMediocrityEnchant.ID, () -> new CurseOfMediocrityEnchant(plugin)); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/DarknessCloakEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/DarknessCloakEnchant.java new file mode 100644 index 0000000..be1432a --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/DarknessCloakEnchant.java @@ -0,0 +1,81 @@ +package su.nightexpress.excellentenchants.enchantment.impl.armor; + +import org.bukkit.Particle; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.particle.SimpleParticle; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; +import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; +import su.nightexpress.excellentenchants.api.enchantment.type.CombatEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; + +public class DarknessCloakEnchant extends ExcellentEnchant implements Chanced, Potioned, CombatEnchant { + + public static final String ID = "darkness_cloak"; + + private ChanceImplementation chanceImplementation; + private PotionImplementation potionImplementation; + + public DarknessCloakEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to apply " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " (" + Placeholders.ENCHANTMENT_POTION_DURATION + "s.) on attacker."); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.2); + } + + @Override + public void loadSettings() { + super.loadSettings(); + this.chanceImplementation = ChanceImplementation.create(this, + "20.0 * " + Placeholders.ENCHANTMENT_LEVEL + " * 0.75"); + + this.potionImplementation = PotionImplementation.create(this, PotionEffectType.DARKNESS, false, + "2.5" + Placeholders.ENCHANTMENT_LEVEL, + Placeholders.ENCHANTMENT_LEVEL); + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @NotNull + @Override + public PotionImplementation getPotionImplementation() { + return potionImplementation; + } + + @Override + @NotNull + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.ARMOR_TORSO; + } + + @Override + public boolean onAttack(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + return false; + } + + @Override + public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + if (!this.isAvailableToUse(victim)) return false; + if (!this.checkTriggerChance(level)) return false; + if (!this.addEffect(damager, level)) return false; + + if (this.hasVisualEffects()) { + SimpleParticle.of(Particle.ASH).play(damager.getEyeLocation(), 0.75, 0.1, 30); + } + + return true; + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantFlameWalker.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantFlameWalker.java index 7fb54fd..43817a1 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantFlameWalker.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/armor/EnchantFlameWalker.java @@ -12,7 +12,9 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockBreakEvent; +import org.bukkit.event.block.BlockExplodeEvent; import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.ItemStack; @@ -28,6 +30,7 @@ import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils; +import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; @@ -75,6 +78,10 @@ public class EnchantFlameWalker extends ExcellentEnchant implements Cleanable { BLOCKS_TO_DESTROY.put(block, Pair.of(System.currentTimeMillis() + (long) seconds * 1000L, Rnd.get(100))); } + public static boolean isBlock(@NotNull Block block) { + return BLOCKS_TO_DESTROY.containsKey(block); + } + @Override @NotNull public EnchantmentTarget getItemTarget() { @@ -111,14 +118,34 @@ public class EnchantFlameWalker extends ExcellentEnchant implements Cleanable { } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onFlameWalkerBlock(BlockBreakEvent e) { - if (BLOCKS_TO_DESTROY.containsKey(e.getBlock())) { - e.setDropItems(false); - e.setExpToDrop(0); - e.getBlock().setType(Material.LAVA); + public void onFlameWalkerBlock(BlockBreakEvent event) { + if (isBlock(event.getBlock())) { + event.setDropItems(false); + event.setExpToDrop(0); + event.getBlock().setType(Material.LAVA); } } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onBlockExplode(EntityExplodeEvent event) { + this.processExplosion(event.blockList()); + } + + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) + public void onBlockExplode2(BlockExplodeEvent event) { + this.processExplosion(event.blockList()); + } + + private void processExplosion(@NotNull List blocks) { + blocks.removeIf(block -> { + if (isBlock(block)) { + block.setType(Material.AIR); + return true; + } + return false; + }); + } + @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onMagmaDamage(EntityDamageEvent e) { if (e.getCause() != EntityDamageEvent.DamageCause.HOT_FLOOR) return; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/DarknessArrowsEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/DarknessArrowsEnchant.java new file mode 100644 index 0000000..dfd41ff --- /dev/null +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/DarknessArrowsEnchant.java @@ -0,0 +1,98 @@ +package su.nightexpress.excellentenchants.enchantment.impl.bow; + +import org.bukkit.Particle; +import org.bukkit.enchantments.EnchantmentTarget; +import org.bukkit.entity.AbstractArrow; +import org.bukkit.entity.Arrow; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Projectile; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.event.entity.EntityShootBowEvent; +import org.bukkit.event.entity.ProjectileHitEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffectType; +import org.jetbrains.annotations.NotNull; +import su.nexmedia.engine.api.particle.SimpleParticle; +import su.nightexpress.excellentenchants.ExcellentEnchants; +import su.nightexpress.excellentenchants.Placeholders; +import su.nightexpress.excellentenchants.api.enchantment.meta.Arrowed; +import su.nightexpress.excellentenchants.api.enchantment.meta.Chanced; +import su.nightexpress.excellentenchants.api.enchantment.meta.Potioned; +import su.nightexpress.excellentenchants.api.enchantment.type.BowEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.ExcellentEnchant; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ArrowImplementation; +import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementation; +import su.nightexpress.excellentenchants.enchantment.impl.meta.PotionImplementation; +import su.nightexpress.excellentenchants.enchantment.util.EnchantPriority; + +public class DarknessArrowsEnchant extends ExcellentEnchant implements Chanced, Arrowed, Potioned, BowEnchant { + + public static final String ID = "darkness_arrows"; + + private ArrowImplementation arrowImplementation; + private ChanceImplementation chanceImplementation; + private PotionImplementation potionImplementation; + + public DarknessArrowsEnchant(@NotNull ExcellentEnchants plugin) { + super(plugin, ID, EnchantPriority.MEDIUM); + this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to launch an arrow with " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " (" + Placeholders.ENCHANTMENT_POTION_DURATION + "s.)"); + this.getDefaults().setLevelMax(3); + this.getDefaults().setTier(0.1); + this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, EnchantBomber.ID); + } + + @Override + public void loadSettings() { + super.loadSettings(); + this.arrowImplementation = ArrowImplementation.create(this, SimpleParticle.of(Particle.ASH)); + this.chanceImplementation = ChanceImplementation.create(this, + "25.0 + " + Placeholders.ENCHANTMENT_LEVEL + " * 5.0"); + this.potionImplementation = PotionImplementation.create(this, PotionEffectType.DARKNESS, false, + "4.0 + " + Placeholders.ENCHANTMENT_LEVEL, + Placeholders.ENCHANTMENT_LEVEL); + } + + @NotNull + @Override + public ArrowImplementation getArrowImplementation() { + return arrowImplementation; + } + + @NotNull + @Override + public ChanceImplementation getChanceImplementation() { + return chanceImplementation; + } + + @NotNull + @Override + public PotionImplementation getPotionImplementation() { + return potionImplementation; + } + + @NotNull + @Override + public EnchantmentTarget getItemTarget() { + return EnchantmentTarget.BOW; + } + + @Override + public boolean onShoot(@NotNull EntityShootBowEvent e, @NotNull LivingEntity shooter, @NotNull ItemStack bow, int level) { + if (!this.isAvailableToUse(shooter)) return false; + if (!(e.getProjectile() instanceof Arrow arrow)) return false; + if (!this.checkTriggerChance(level)) return false; + + arrow.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED); + return arrow.addCustomEffect(this.createEffect(level), true); + } + + @Override + public boolean onHit(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) { + return this.isOurProjectile(projectile); + } + + @Override + public boolean onDamage(@NotNull EntityDamageByEntityEvent e, @NotNull Projectile projectile, @NotNull LivingEntity shooter, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) { + return this.isOurProjectile(projectile); + } +} diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantBomber.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantBomber.java index a7116ab..4f6d58f 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantBomber.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantBomber.java @@ -37,7 +37,8 @@ public class EnchantBomber extends ExcellentEnchant implements Chanced, BowEncha EnchantEnderBow.ID, EnchantGhast.ID, EnchantExplosiveArrows.ID, EnchantPoisonedArrows.ID, EnchantConfusingArrows.ID, EnchantWitheredArrows.ID, EnchantElectrifiedArrows.ID, EnchantDragonfireArrows.ID, - EnchantHover.ID, + DarknessArrowsEnchant.ID, + EnchantHover.ID, FlareEnchant.ID, Enchantment.ARROW_FIRE.getKey().getKey(), Enchantment.ARROW_KNOCKBACK.getKey().getKey(), Enchantment.ARROW_DAMAGE.getKey().getKey() diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantConfusingArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantConfusingArrows.java index f749165..0b17a99 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantConfusingArrows.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantConfusingArrows.java @@ -38,11 +38,7 @@ public class EnchantConfusingArrows extends ExcellentEnchant implements Chanced, this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to launch an arrow with " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " (" + Placeholders.ENCHANTMENT_POTION_DURATION + "s.)"); this.getDefaults().setLevelMax(3); this.getDefaults().setTier(0.1); - this.getDefaults().setConflicts( - EnchantEnderBow.ID, EnchantGhast.ID, EnchantBomber.ID, EnchantHover.ID, - EnchantExplosiveArrows.ID, EnchantPoisonedArrows.ID, - EnchantWitheredArrows.ID, EnchantElectrifiedArrows.ID, EnchantDragonfireArrows.ID - ); + this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, EnchantBomber.ID); } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantDragonfireArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantDragonfireArrows.java index 6aeb214..401b792 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantDragonfireArrows.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantDragonfireArrows.java @@ -47,12 +47,7 @@ public class EnchantDragonfireArrows extends ExcellentEnchant implements Chanced this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to launch an dragonfire arrow (R=" + PLACEHOLDER_FIRE_RADIUS + ", " + PLACEHOLDER_FIRE_DURATION + "s)."); this.getDefaults().setLevelMax(3); this.getDefaults().setTier(0.7); - - this.getDefaults().setConflicts( - EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, - EnchantExplosiveArrows.ID, EnchantPoisonedArrows.ID, EnchantConfusingArrows.ID, - EnchantWitheredArrows.ID, EnchantElectrifiedArrows.ID - ); + this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, EnchantBomber.ID); } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantElectrifiedArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantElectrifiedArrows.java index d959a48..62f7d0c 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantElectrifiedArrows.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantElectrifiedArrows.java @@ -42,12 +42,7 @@ public class EnchantElectrifiedArrows extends ExcellentEnchant implements Chance this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to launch an electrified arrow."); this.getDefaults().setLevelMax(3); this.getDefaults().setTier(0.3); - - this.getDefaults().setConflicts( - EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, - EnchantExplosiveArrows.ID, EnchantPoisonedArrows.ID, EnchantConfusingArrows.ID, - EnchantWitheredArrows.ID, EnchantDragonfireArrows.ID - ); + this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, EnchantBomber.ID); } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantEnderBow.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantEnderBow.java index e623526..17d0cad 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantEnderBow.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantEnderBow.java @@ -33,7 +33,8 @@ public class EnchantEnderBow extends ExcellentEnchant implements BowEnchant, Cha EnchantBomber.ID, EnchantGhast.ID, EnchantExplosiveArrows.ID, EnchantPoisonedArrows.ID, EnchantConfusingArrows.ID, EnchantWitheredArrows.ID, EnchantElectrifiedArrows.ID, EnchantDragonfireArrows.ID, - EnchantHover.ID, + DarknessArrowsEnchant.ID, + EnchantHover.ID, FlareEnchant.ID, Enchantment.ARROW_FIRE.getKey().getKey(), Enchantment.ARROW_KNOCKBACK.getKey().getKey(), Enchantment.ARROW_DAMAGE.getKey().getKey() diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantExplosiveArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantExplosiveArrows.java index 99ebe9c..58c18a3 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantExplosiveArrows.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantExplosiveArrows.java @@ -47,12 +47,7 @@ public class EnchantExplosiveArrows extends ExcellentEnchant implements Chanced, this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to launch an explosive arrow."); this.getDefaults().setLevelMax(3); this.getDefaults().setTier(0.7); - - this.getDefaults().setConflicts( - EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, - EnchantPoisonedArrows.ID, EnchantConfusingArrows.ID, - EnchantWitheredArrows.ID, EnchantElectrifiedArrows.ID, EnchantDragonfireArrows.ID - ); + this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, EnchantBomber.ID); } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantGhast.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantGhast.java index 233a14f..5f63afe 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantGhast.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantGhast.java @@ -40,7 +40,8 @@ public class EnchantGhast extends ExcellentEnchant implements BowEnchant, Chance EnchantEnderBow.ID, EnchantBomber.ID, EnchantExplosiveArrows.ID, EnchantPoisonedArrows.ID, EnchantConfusingArrows.ID, EnchantWitheredArrows.ID, EnchantElectrifiedArrows.ID, EnchantDragonfireArrows.ID, - EnchantHover.ID, + DarknessArrowsEnchant.ID, + EnchantHover.ID, FlareEnchant.ID, Enchantment.ARROW_FIRE.getKey().getKey(), Enchantment.ARROW_KNOCKBACK.getKey().getKey(), Enchantment.ARROW_DAMAGE.getKey().getKey() diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantHover.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantHover.java index 88d34d5..da52935 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantHover.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantHover.java @@ -38,11 +38,7 @@ public class EnchantHover extends ExcellentEnchant implements Chanced, Arrowed, this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to launch an arrow with " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " (" + Placeholders.ENCHANTMENT_POTION_DURATION + "s.)"); this.getDefaults().setLevelMax(3); this.getDefaults().setTier(0.1); - this.getDefaults().setConflicts( - EnchantEnderBow.ID, EnchantGhast.ID, EnchantBomber.ID, - EnchantExplosiveArrows.ID, EnchantPoisonedArrows.ID, EnchantConfusingArrows.ID, - EnchantWitheredArrows.ID, EnchantElectrifiedArrows.ID, EnchantDragonfireArrows.ID - ); + this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, EnchantBomber.ID); } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantPoisonedArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantPoisonedArrows.java index d435a1d..133da9c 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantPoisonedArrows.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantPoisonedArrows.java @@ -38,12 +38,7 @@ public class EnchantPoisonedArrows extends ExcellentEnchant implements Chanced, this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to launch an arrow with " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " (" + Placeholders.ENCHANTMENT_POTION_DURATION + "s.)"); this.getDefaults().setLevelMax(3); this.getDefaults().setTier(0.1); - - this.getDefaults().setConflicts( - EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, - EnchantExplosiveArrows.ID, EnchantConfusingArrows.ID, - EnchantWitheredArrows.ID, EnchantElectrifiedArrows.ID, EnchantDragonfireArrows.ID - ); + this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, EnchantBomber.ID); } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantWitheredArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantWitheredArrows.java index 7facc29..74f8231 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantWitheredArrows.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/bow/EnchantWitheredArrows.java @@ -38,12 +38,7 @@ public class EnchantWitheredArrows extends ExcellentEnchant implements Chanced, this.getDefaults().setDescription(Placeholders.ENCHANTMENT_CHANCE + "% chance to launch an arrow with " + Placeholders.ENCHANTMENT_POTION_TYPE + " " + Placeholders.ENCHANTMENT_POTION_LEVEL + " (" + Placeholders.ENCHANTMENT_POTION_DURATION + "s.)"); this.getDefaults().setLevelMax(3); this.getDefaults().setTier(0.5); - - this.getDefaults().setConflicts( - EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, - EnchantExplosiveArrows.ID, EnchantPoisonedArrows.ID, EnchantConfusingArrows.ID, - EnchantElectrifiedArrows.ID, EnchantDragonfireArrows.ID - ); + this.getDefaults().setConflicts(EnchantEnderBow.ID, EnchantGhast.ID, EnchantHover.ID, EnchantBomber.ID); } @Override diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java index 77b218b..197692e 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/CurseOfMediocrityEnchant.java @@ -62,12 +62,12 @@ public class CurseOfMediocrityEnchant extends ExcellentEnchant implements Chance } @Override - public boolean onDrop(@NotNull BlockDropItemEvent e, @NotNull EnchantDropContainer dropContainer, + public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { if (!this.isAvailableToUse(player)) return false; if (!this.checkTriggerChance(level)) return false; - e.getItems().forEach(drop -> { + event.getItems().forEach(drop -> { ItemStack stack = drop.getItemStack(); ItemUtil.mapMeta(stack, meta -> { meta.getEnchants().keySet().forEach(meta::removeEnchant); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantDivineTouch.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantDivineTouch.java index 6b9643b..c92c32d 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantDivineTouch.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantDivineTouch.java @@ -102,8 +102,8 @@ public class EnchantDivineTouch extends ExcellentEnchant implements Chanced, Blo } @Override - public boolean onDrop(@NotNull BlockDropItemEvent e, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { - BlockState state = e.getBlockState(); + public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { + BlockState state = event.getBlockState(); Block block = state.getBlock(); if (!block.hasMetadata(META_HANDLE)) return false; if (!(state instanceof CreatureSpawner spawnerBlock)) return false; diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantSilkChest.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantSilkChest.java index 3c5b5aa..a289d30 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantSilkChest.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantSilkChest.java @@ -130,23 +130,29 @@ public class EnchantSilkChest extends ExcellentEnchant implements BlockDropEncha } @Override - public boolean onDrop(@NotNull BlockDropItemEvent e, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { - BlockState state = e.getBlockState(); + public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull EnchantDropContainer dropContainer, + @NotNull Player player, @NotNull ItemStack item, int level) { + BlockState state = event.getBlockState(); Block block = state.getBlock(); if (!this.isAvailableToUse(player)) return false; if (!(state instanceof Chest chest)) return false; // Добавляем в сундук обратно предметы из дроп листа, кроме самого сундука. - e.getItems().removeIf(drop -> drop.getItemStack().getType() == state.getType() && drop.getItemStack().getAmount() == 1); - chest.getBlockInventory().addItem(e.getItems().stream().map(Item::getItemStack).toList().toArray(new ItemStack[0])); + event.getItems().removeIf(drop -> drop.getItemStack().getType() == state.getType() && drop.getItemStack().getAmount() == 1); + chest.getBlockInventory().addItem(event.getItems().stream().map(Item::getItemStack).toList().toArray(new ItemStack[0])); + + if (chest.getBlockInventory().isEmpty()) { + dropContainer.getDrop().add(new ItemStack(chest.getType())); + return false; + } // Добавляем кастомный сундук в кастомный дроп лист. dropContainer.getDrop().add(this.getSilkChest(chest)); // Очищаем инвентарь сундука и дефолтный дроп лист. chest.getBlockInventory().clear(); - e.getItems().clear(); + event.getItems().clear(); return true; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantSmelter.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantSmelter.java index 96419f5..d544ebe 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantSmelter.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantSmelter.java @@ -89,18 +89,18 @@ public class EnchantSmelter extends ExcellentEnchant implements Chanced, BlockDr } @Override - public boolean onDrop(@NotNull BlockDropItemEvent e, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { - if (e.getBlockState() instanceof Container) return false; + public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { + if (event.getBlockState() instanceof Container) return false; if (!this.isAvailableToUse(player)) return false; if (!this.checkTriggerChance(level)) return false; - if (e.getItems().stream().noneMatch(drop -> this.isSmeltable(drop.getItemStack().getType()))) return false; + if (event.getItems().stream().noneMatch(drop -> this.isSmeltable(drop.getItemStack().getType()))) return false; - e.getItems().forEach(drop -> { + event.getItems().forEach(drop -> { Material material = this.smeltingTable.get(drop.getItemStack().getType()); if (material != null) drop.getItemStack().setType(material); }); - Block block = e.getBlockState().getBlock(); + Block block = event.getBlockState().getBlock(); if (this.hasVisualEffects()) { Location location = LocationUtil.getCenter(block.getLocation(), true); LocationUtil.sound(location, this.sound); diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTelekinesis.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTelekinesis.java index 73c720f..8fde3f0 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTelekinesis.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTelekinesis.java @@ -58,18 +58,18 @@ public class EnchantTelekinesis extends ExcellentEnchant implements Chanced, Blo } @Override - public boolean onDrop(@NotNull BlockDropItemEvent e, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { + public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { if (!this.isAvailableToUse(player)) return false; if (!this.checkTriggerChance(level)) return false; List drops = new ArrayList<>(); - drops.addAll(e.getItems().stream().map(Item::getItemStack).toList()); + drops.addAll(event.getItems().stream().map(Item::getItemStack).toList()); drops.addAll(dropContainer.getDrop()); drops.removeIf(Objects::isNull); drops.forEach(drop -> PlayerUtil.addItem(player, drop)); dropContainer.getDrop().clear(); - e.getItems().clear(); + event.getItems().clear(); return true; } diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTreasures.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTreasures.java index 387092a..e2b5d9f 100644 --- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTreasures.java +++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/tool/EnchantTreasures.java @@ -136,8 +136,8 @@ public class EnchantTreasures extends ExcellentEnchant implements Chanced, Block } @Override - public boolean onDrop(@NotNull BlockDropItemEvent e, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { - Block block = e.getBlockState().getBlock(); + public boolean onDrop(@NotNull BlockDropItemEvent event, @NotNull EnchantDropContainer dropContainer, @NotNull Player player, @NotNull ItemStack item, int level) { + Block block = event.getBlockState().getBlock(); if (block.hasMetadata(META)) { block.removeMetadata(META, plugin); return false; @@ -145,7 +145,7 @@ public class EnchantTreasures extends ExcellentEnchant implements Chanced, Block if (!this.isAvailableToUse(player)) return false; if (!this.checkTriggerChance(level)) return false; - dropContainer.getDrop().addAll(this.getTreasures(e.getBlockState().getType())); + dropContainer.getDrop().addAll(this.getTreasures(event.getBlockState().getType())); return true; } diff --git a/Core/src/main/resources/lang/messages_ru.yml b/Core/src/main/resources/lang/messages_ru.yml index 9e33cf0..e0f46f1 100644 --- a/Core/src/main/resources/lang/messages_ru.yml +++ b/Core/src/main/resources/lang/messages_ru.yml @@ -1,10 +1,6 @@ -# +---------------------------------------------------------+ -# | Официальная русская версия. | -# | Публикация на помойках rubukkit и spigotru ЗАПРЕЩЕНА. | -# +---------------------------------------------------------+ Command: List: - Desc: 'Список всех нестандартных зачарований.' + Desc: 'Меню дополнительных зачарований.' Enchant: Usage: '<зачарование> <уровень>' Desc: 'Зачарование предмета в руке.'