This commit is contained in:
nulli0n 2022-08-09 19:36:32 +05:00
parent 559e70da9a
commit 2b864e97a2
4 changed files with 62 additions and 25 deletions

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId>
<version>3.2.5</version>
<version>3.2.6</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -21,6 +21,10 @@
<id>md_5-releases</id>
<url>https://repo.md-5.net/content/repositories/releases/</url>
</repository>
<repository>
<id>sk89q-repo</id>
<url>https://maven.enginehub.org/repo/</url>
</repository>
</repositories>
<dependencies>
@ -32,22 +36,22 @@
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>NMS</artifactId>
<version>3.2.5</version>
<version>3.2.6</version>
</dependency>
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_17_R1</artifactId>
<version>3.2.5</version>
<version>3.2.6</version>
</dependency>
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_18_R2</artifactId>
<version>3.2.5</version>
<version>3.2.6</version>
</dependency>
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_19_R1</artifactId>
<version>3.2.5</version>
<version>3.2.6</version>
</dependency>
<dependency>
<groupId>fr.neatmonster</groupId>
@ -55,6 +59,12 @@
<version>3.16.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-bukkit</artifactId>
<version>7.0.6</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -46,6 +46,10 @@ public class EnchantHandlerListener extends AbstractListener<ExcellentEnchants>
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<ExcellentEnchants>
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);
}
// ---------------------------------------------------------------