diff --git a/Core/pom.xml b/Core/pom.xml
index 22aa57e..11f6598 100644
--- a/Core/pom.xml
+++ b/Core/pom.xml
@@ -5,7 +5,7 @@
ExcellentEnchants
su.nightexpress.excellentenchants
- 3.3.0.2
+ 3.3.0.3
4.0.0
@@ -45,27 +45,27 @@
su.nightexpress.excellentenchants
NMS
- 3.3.0.2
+ 3.3.0.3
su.nightexpress.excellentenchants
V1_17_R1
- 3.3.0.2
+ 3.3.0.3
su.nightexpress.excellentenchants
V1_18_R2
- 3.3.0.2
+ 3.3.0.3
su.nightexpress.excellentenchants
V1_19_R1
- 3.3.0.2
+ 3.3.0.3
su.nightexpress.excellentenchants
V1_19_R2
- 3.3.0.2
+ 3.3.0.3
fr.neatmonster
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 2709dd0..cfbdd90 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
@@ -3,12 +3,16 @@ package su.nightexpress.excellentenchants.enchantment.impl.bow;
import org.bukkit.Particle;
import org.bukkit.block.Block;
import org.bukkit.enchantments.EnchantmentTarget;
+import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Projectile;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
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.metadata.FixedMetadataValue;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.utils.EffectUtil;
import su.nexmedia.engine.utils.LocationUtil;
@@ -25,6 +29,8 @@ public class EnchantElectrifiedArrows extends ExcellentEnchant implements Chance
public static final String ID = "electrified_arrows";
+ private static final String META_NO_ITEM_DAMAGE = "itemNoDamage";
+
private ArrowImplementation arrowImplementation;
private ChanceImplementation chanceImplementation;
@@ -70,7 +76,7 @@ public class EnchantElectrifiedArrows extends ExcellentEnchant implements Chance
if (e.getHitEntity() != null || e.getHitBlock() == null) return false;
Block block = e.getHitBlock();
- block.getWorld().strikeLightning(block.getLocation());
+ block.getWorld().strikeLightning(block.getLocation()).setMetadata(META_NO_ITEM_DAMAGE, new FixedMetadataValue(plugin, true));
if (this.hasVisualEffects()) {
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);
@@ -83,10 +89,20 @@ public class EnchantElectrifiedArrows extends ExcellentEnchant implements Chance
if (!this.isOurProjectile(projectile)) return false;
plugin.getServer().getScheduler().runTask(plugin, () -> {
+ if (victim.isDead()) return;
victim.setNoDamageTicks(0);
- victim.getWorld().strikeLightning(victim.getLocation());
+ victim.getWorld().strikeLightning(victim.getLocation()).setMetadata(META_NO_ITEM_DAMAGE, new FixedMetadataValue(plugin, true));
});
return true;
}
+
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
+ public void onItemDamage(EntityDamageByEntityEvent e) {
+ if (!e.getDamager().hasMetadata(META_NO_ITEM_DAMAGE)) return;
+ if (!(e.getEntity() instanceof Item item)) return;
+
+ e.setCancelled(true);
+ item.setFireTicks(0);
+ }
}
diff --git a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantThunder.java b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantThunder.java
index 5566248..98e4995 100644
--- a/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantThunder.java
+++ b/Core/src/main/java/su/nightexpress/excellentenchants/enchantment/impl/weapon/EnchantThunder.java
@@ -1,9 +1,13 @@
package su.nightexpress.excellentenchants.enchantment.impl.weapon;
import org.bukkit.enchantments.EnchantmentTarget;
+import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack;
+import org.bukkit.metadata.FixedMetadataValue;
import org.jetbrains.annotations.NotNull;
import su.nexmedia.engine.api.config.JOption;
import su.nightexpress.excellentenchants.ExcellentEnchants;
@@ -16,6 +20,8 @@ import su.nightexpress.excellentenchants.enchantment.impl.meta.ChanceImplementat
public class EnchantThunder extends ExcellentEnchant implements Chanced, CombatEnchant {
public static final String ID = "thunder";
+
+ private static final String META_NO_ITEM_DAMAGE = "noItemDamage";
private boolean inThunderstormOnly;
private ChanceImplementation chanceImplementation;
@@ -56,8 +62,9 @@ public class EnchantThunder extends ExcellentEnchant implements Chanced, CombatE
if (!this.checkTriggerChance(level)) return false;
plugin.getServer().getScheduler().runTask(plugin, () -> {
+ if (victim.isDead()) return;
victim.setNoDamageTicks(0);
- victim.getWorld().strikeLightning(victim.getLocation());
+ victim.getWorld().strikeLightning(victim.getLocation()).setMetadata(META_NO_ITEM_DAMAGE, new FixedMetadataValue(plugin, true));
});
return true;
@@ -67,4 +74,13 @@ public class EnchantThunder extends ExcellentEnchant implements Chanced, CombatE
public boolean onProtect(@NotNull EntityDamageByEntityEvent e, @NotNull LivingEntity damager, @NotNull LivingEntity victim, @NotNull ItemStack weapon, int level) {
return false;
}
+
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
+ public void onItemDamage(EntityDamageByEntityEvent e) {
+ if (!e.getDamager().hasMetadata(META_NO_ITEM_DAMAGE)) return;
+ if (!(e.getEntity() instanceof Item item)) return;
+
+ e.setCancelled(true);
+ item.setFireTicks(0);
+ }
}
diff --git a/NMS/pom.xml b/NMS/pom.xml
index f543476..53441d4 100644
--- a/NMS/pom.xml
+++ b/NMS/pom.xml
@@ -5,7 +5,7 @@
ExcellentEnchants
su.nightexpress.excellentenchants
- 3.3.0.2
+ 3.3.0.3
4.0.0
diff --git a/V1_17_R1/pom.xml b/V1_17_R1/pom.xml
index 41bd7ab..f60befc 100644
--- a/V1_17_R1/pom.xml
+++ b/V1_17_R1/pom.xml
@@ -5,7 +5,7 @@
ExcellentEnchants
su.nightexpress.excellentenchants
- 3.3.0.2
+ 3.3.0.3
4.0.0
@@ -26,7 +26,7 @@
su.nightexpress.excellentenchants
NMS
- 3.3.0.2
+ 3.3.0.3
diff --git a/V1_18_R2/pom.xml b/V1_18_R2/pom.xml
index 56a51b5..1a202cc 100644
--- a/V1_18_R2/pom.xml
+++ b/V1_18_R2/pom.xml
@@ -5,7 +5,7 @@
ExcellentEnchants
su.nightexpress.excellentenchants
- 3.3.0.2
+ 3.3.0.3
4.0.0
@@ -26,7 +26,7 @@
su.nightexpress.excellentenchants
NMS
- 3.3.0.2
+ 3.3.0.3
diff --git a/V1_19_R1/pom.xml b/V1_19_R1/pom.xml
index 7fbd06e..9fa190a 100644
--- a/V1_19_R1/pom.xml
+++ b/V1_19_R1/pom.xml
@@ -5,7 +5,7 @@
ExcellentEnchants
su.nightexpress.excellentenchants
- 3.3.0.2
+ 3.3.0.3
4.0.0
@@ -26,7 +26,7 @@
su.nightexpress.excellentenchants
NMS
- 3.3.0.2
+ 3.3.0.3
diff --git a/V1_19_R2/pom.xml b/V1_19_R2/pom.xml
index 6a134be..177f3e2 100644
--- a/V1_19_R2/pom.xml
+++ b/V1_19_R2/pom.xml
@@ -5,7 +5,7 @@
ExcellentEnchants
su.nightexpress.excellentenchants
- 3.3.0.2
+ 3.3.0.3
4.0.0
@@ -26,7 +26,7 @@
su.nightexpress.excellentenchants
NMS
- 3.3.0.2
+ 3.3.0.3
diff --git a/pom.xml b/pom.xml
index e7cbd84..39bd877 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
su.nightexpress.excellentenchants
ExcellentEnchants
pom
- 3.3.0.2
+ 3.3.0.3
Core
NMS