Skip to content

Commit

Permalink
fix lightning effect
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Oct 24, 2023
1 parent 5198c91 commit a5cef23
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.xginko</groupId>
<artifactId>PumpkinPVPReloaded</artifactId>
<version>1.2.1</version>
<version>1.2.2</version>
<packaging>jar</packaging>

<name>PumpkinPVPReloaded</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,30 +50,30 @@ public void disable() {
@EventHandler(priority = EventPriority.LOW)
private void onPostPumpkinExplode(PostPumpkinExplodeEvent event) {
if (!event.hasExploded()) return;
if (probability >= 1.0 || new Random().nextDouble() > probability) return;
if (probability >= 1 || new Random().nextDouble() <= probability) {
final UUID exploder = event.getExploder().getUniqueId();
final Location explosionLoc = event.getExplodeLocation();

final UUID exploder = event.getExploder().getUniqueId();
final Location explosionLoc = event.getExplodeLocation();

Player closestPlayer = null;
double distance = 100;
for (Player player : explosionLoc.getNearbyPlayers(6,6,6)) {
if (player.getUniqueId().equals(exploder)) continue;
double currentDistance = explosionLoc.distance(player.getLocation());
if (currentDistance < distance) {
closestPlayer = player;
distance = currentDistance;
Player closestPlayer = null;
double distance = 100;
for (Player player : explosionLoc.getNearbyPlayers(6, 6, 6)) {
if (player.getUniqueId().equals(exploder)) continue;
double currentDistance = explosionLoc.distance(player.getLocation());
if (currentDistance < distance) {
closestPlayer = player;
distance = currentDistance;
}
}
}

if (closestPlayer == null) return;
final Location playerLoc = closestPlayer.getLocation();
final World world = playerLoc.getWorld();
if (closestPlayer == null) return;
final Location playerLoc = closestPlayer.getLocation();
final World world = playerLoc.getWorld();

closestPlayer.getScheduler().run(plugin, strike -> {
for (int i = 0; i < spawn_amount; i++) {
(deal_damage ? world.strikeLightning(playerLoc) : world.strikeLightningEffect(playerLoc)).setFlashCount(flashcount);
}
}, null);
closestPlayer.getScheduler().run(plugin, strike -> {
for (int i = 0; i < spawn_amount; i++) {
(deal_damage ? world.strikeLightning(playerLoc) : world.strikeLightningEffect(playerLoc)).setFlashCount(flashcount);
}
}, null);
}
}
}

0 comments on commit a5cef23

Please sign in to comment.