Skip to content

Commit

Permalink
Improved PR
Browse files Browse the repository at this point in the history
  • Loading branch information
WillFP committed Sep 14, 2021
1 parent 49965c0 commit a65f16c
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions eco-api/src/main/java/com/willfp/eco/util/LightningUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import lombok.experimental.UtilityClass;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.SoundCategory;
import org.bukkit.entity.LivingEntity;
import org.jetbrains.annotations.NotNull;

Expand All @@ -21,21 +20,26 @@ public class LightningUtils {
* @param silent If the lightning sound should be played locally
*/
public void strike(@NotNull final LivingEntity victim,
final double damage, boolean silent) {
final double damage,
final boolean silent) {
Location loc = victim.getLocation();

if (silent) {
victim.getWorld().spigot().strikeLightningEffect(loc, true);
victim.getWorld().playSound(loc, Sound.ENTITY_LIGHTNING_BOLT_IMPACT, 1, 1);
}
else {
} else {
victim.getWorld().strikeLightningEffect(loc);
}

victim.damage(damage);
}


/**
* Strike lightning on a victim without fire.
*
* @param victim The entity to smite.
* @param damage The damage to deal.
*/
public void strike(@NotNull final LivingEntity victim,
final double damage) {
strike(victim, damage, false);
Expand Down

0 comments on commit a65f16c

Please sign in to comment.