diff --git a/Core/pom.xml b/Core/pom.xml
index 9bfab09..3310d9c 100644
--- a/Core/pom.xml
+++ b/Core/pom.xml
@@ -5,7 +5,7 @@
ExcellentEnchants
su.nightexpress.excellentenchants
- 3.2.5
+ 3.2.6
4.0.0
@@ -21,6 +21,10 @@
md_5-releases
https://repo.md-5.net/content/repositories/releases/
+
+ sk89q-repo
+ https://maven.enginehub.org/repo/
+
@@ -32,22 +36,22 @@
su.nightexpress.excellentenchants
NMS
- 3.2.5
+ 3.2.6
su.nightexpress.excellentenchants
V1_17_R1
- 3.2.5
+ 3.2.6
su.nightexpress.excellentenchants
V1_18_R2
- 3.2.5
+ 3.2.6
su.nightexpress.excellentenchants
V1_19_R1
- 3.2.5
+ 3.2.6
fr.neatmonster
@@ -55,6 +59,12 @@
3.16.1-SNAPSHOT
provided
+
+ com.sk89q.worldguard
+ worldguard-bukkit
+ 7.0.6
+ provided
+
diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantDragonfireArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantDragonfireArrows.java
index cd08b84..22c8608 100644
--- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantDragonfireArrows.java
+++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantDragonfireArrows.java
@@ -1,14 +1,19 @@
package su.nightexpress.excellentenchants.manager.enchants.bow;
+import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.World;
import org.bukkit.entity.AreaEffectCloud;
+import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Projectile;
+import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
+import org.bukkit.projectiles.ProjectileSource;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import su.nexmedia.engine.api.config.JYML;
import su.nexmedia.engine.utils.NumberUtil;
import su.nightexpress.excellentenchants.ExcellentEnchants;
@@ -56,20 +61,33 @@ public class EnchantDragonfireArrows extends IEnchantBowTemplate {
return this.fireRadius.getValue(level);
}
+ @Override
+ public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) {
+ if (!super.use(e, damager, victim, weapon, level)) return false;
+
+ this.createCloud(damager, victim.getLocation(), level);
+ return true;
+ }
+
@Override
public boolean use(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) {
if (!super.use(e, projectile, bow, level)) return false;
- World world = projectile.getWorld();
- AreaEffectCloud cloud = world.spawn(projectile.getLocation(), AreaEffectCloud.class);
+ this.createCloud(projectile.getShooter(), projectile.getLocation() , level);
+ return true;
+ }
+
+ private void createCloud(@Nullable ProjectileSource shooter, @NotNull Location location, int level) {
+ World world = location.getWorld();
+ if (world == null) return;
+
+ AreaEffectCloud cloud = world.spawn(location, AreaEffectCloud.class);
cloud.clearCustomEffects();
- cloud.setSource(projectile.getShooter());
+ cloud.setSource(shooter);
cloud.setParticle(Particle.DRAGON_BREATH);
cloud.setRadius((float) this.getFireRadius(level));
cloud.setDuration(this.getFireDuration(level));
cloud.setRadiusPerTick((7.0F - cloud.getRadius()) / (float) cloud.getDuration());
cloud.addCustomEffect(new PotionEffect(PotionEffectType.HARM, 1, 1), true);
-
- return true;
}
}
diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantElectrifiedArrows.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantElectrifiedArrows.java
index a0e9954..b97f186 100644
--- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantElectrifiedArrows.java
+++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/enchants/bow/EnchantElectrifiedArrows.java
@@ -2,9 +2,9 @@ package su.nightexpress.excellentenchants.manager.enchants.bow;
import org.bukkit.Particle;
import org.bukkit.block.Block;
-import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Projectile;
+import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.ProjectileHitEvent;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
@@ -23,25 +23,27 @@ public class EnchantElectrifiedArrows extends IEnchantBowTemplate {
super(plugin, cfg, EnchantPriority.MEDIUM);
}
+ @Override
+ public boolean use(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) {
+ if (!super.use(e, damager, victim, weapon, level)) return false;
+
+ plugin.getServer().getScheduler().runTask(plugin, () -> {
+ victim.setNoDamageTicks(0);
+ victim.getWorld().strikeLightning(victim.getLocation());
+ });
+
+ return true;
+ }
+
@Override
public boolean use(@NotNull ProjectileHitEvent e, @NotNull Projectile projectile, @NotNull ItemStack bow, int level) {
if (!super.use(e, projectile, bow, level)) return false;
+ if (e.getHitEntity() != null || e.getHitBlock() == null) return false;
- Entity entity = e.getHitEntity();
Block block = e.getHitBlock();
-
- if (entity instanceof LivingEntity victim) {
- plugin.getServer().getScheduler().runTask(plugin, () -> {
- victim.setNoDamageTicks(0);
- victim.getWorld().strikeLightning(victim.getLocation());
- });
- }
- else if (block != null) {
- block.getWorld().strikeLightning(block.getLocation());
- EffectUtil.playEffect(LocationUtil.getCenter(block.getLocation()), Particle.BLOCK_CRACK, block.getType().name(), 1D, 1D, 1D, 0.05, 150);
- EffectUtil.playEffect(LocationUtil.getCenter(block.getLocation()), Particle.FIREWORKS_SPARK, "", 1D, 1D, 1D, 0.05, 150);
- }
- else return false;
+ block.getWorld().strikeLightning(block.getLocation());
+ EffectUtil.playEffect(LocationUtil.getCenter(block.getLocation()), Particle.BLOCK_CRACK, block.getType().name(), 1D, 1D, 1D, 0.05, 150);
+ EffectUtil.playEffect(LocationUtil.getCenter(block.getLocation()), Particle.FIREWORKS_SPARK, "", 1D, 1D, 1D, 0.05, 150);
return true;
}
diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java b/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java
index c9f725c..de8bcaf 100644
--- a/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java
+++ b/Core/src/main/java/su/nightexpress/excellentenchants/manager/listeners/EnchantHandlerListener.java
@@ -46,6 +46,10 @@ public class EnchantHandlerListener extends AbstractListener
return projectile.hasMetadata(META_PROJECTILE_WEAPON) ? (ItemStack) projectile.getMetadata(META_PROJECTILE_WEAPON).get(0).value() : null;
}
+ private void removeSourceWeapon(@NotNull Projectile projectile) {
+ projectile.removeMetadata(META_PROJECTILE_WEAPON, plugin);
+ }
+
// ---------------------------------------------------------------
// Combat Attacking Enchants
// ---------------------------------------------------------------
@@ -150,6 +154,9 @@ public class EnchantHandlerListener extends AbstractListener
EnchantManager.getItemCustomEnchants(bow, BowEnchant.class).forEach((bowEnchant, level) -> {
bowEnchant.use(e, projectile, bow, level);
});
+
+ // Prevent to apply enchants multiple times on hits.
+ this.removeSourceWeapon(projectile);
}
// ---------------------------------------------------------------