Skip to content

Commit

Permalink
fix indexoutofboundsexception
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Nov 15, 2023
1 parent 1848571 commit 19181c7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 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.5.0</version>
<version>1.5.1</version>
<packaging>jar</packaging>

<name>PumpkinPVPReloaded</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,11 @@ private void onPostPumpkinHeadExplode(PostPumpkinHeadEntityExplodeEvent event) {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
private void onPlayerDeath(PlayerDeathEvent event) {
if (isNearPumpkinExplosion(event.getEntity().getLocation())) {
event.setDeathSound(this.getRandomDeathsound());
event.setDeathSound(this.deathSounds.get(new Random().nextInt(this.deathSounds.size())));
if (volume != -1.0F) event.setDeathSoundVolume(volume);
}
}

private Sound getRandomDeathsound() {
// Try to get a 0 naturally without having an origin value in Random (I hate using old jdk's)
return this.deathSounds.get(new Random().nextInt(this.deathSounds.size() + 1) - 1);
}

private boolean isNearPumpkinExplosion(Location playerLoc) {
for (Map.Entry<Location, Float> explosion : this.pumpkinExplosions.asMap().entrySet()) {
final Location explosionLoc = explosion.getKey();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public FireworkEffects() {
int tries = 0;
while (secondary_color.equals(primary_color)) { // Avoid rolling the same color
if (tries > 100) break; // Avoid infinite loop on bad config
secondary_color = parsedColors.get(new Random().nextInt(parsedColors.size() + 1) - 1);
secondary_color = parsedColors.get(new Random().nextInt(parsedColors.size()));
tries++;
}
this.fireWorkEffects.add(FireworkEffect.builder()
Expand Down Expand Up @@ -101,8 +101,7 @@ public void disable() {
}

private FireworkEffect getRandomEffect() {
// Try to get a 0 naturally without having an origin value in Random (I hate using old jdk's)
return this.fireWorkEffects.get(new Random().nextInt(this.fireWorkEffects.size() + 1) - 1);
return this.fireWorkEffects.get(new Random().nextInt(this.fireWorkEffects.size()));
}

@EventHandler(priority = EventPriority.LOWEST)
Expand Down

0 comments on commit 19181c7

Please sign in to comment.