Add next-wave-delay per-arena setting.

This commit adds a new per-arena config-file setting, next-wave-delay. When a new wave is about to spawn, a positive next-wave-delay value will cause the spawning of the wave to be delayed by that amount of seconds, similar to how first-wave-delay delays the spawning of the first wave.

By moving all of the actual spawning logic into a new method and simply referencing that as a Runnable, we can avoid having to set weird boolean flags and re-scheduling the MASpawnThread itself.

Closes #449
This commit is contained in:
Andreas Troelsen 2018-07-29 21:23:29 +02:00
parent 6f077359c6
commit 7a9b2f601f
2 changed files with 15 additions and 0 deletions

View File

@ -38,6 +38,7 @@ public class MASpawnThread implements Runnable
private int playerCount, monsterLimit;
private boolean waveClear, bossClear, preBossClear, wavesAsLevel;
private int waveInterval;
private int nextWaveDelay;
/**
* Create a new monster spawner for the input arena.
@ -70,6 +71,7 @@ public class MASpawnThread implements Runnable
preBossClear = arena.getSettings().getBoolean("clear-wave-before-boss", false);
wavesAsLevel = arena.getSettings().getBoolean("display-waves-as-level", false);
waveInterval = arena.getSettings().getInt("wave-interval", 3);
nextWaveDelay = arena.getSettings().getInt("next-wave-delay", 0);
}
public void run() {
@ -104,6 +106,18 @@ public class MASpawnThread implements Runnable
return;
}
// Delay the next wave
if (nextWaveDelay > 0) {
arena.scheduleTask(this::spawnNextWave, nextWaveDelay * 20);
} else {
spawnNextWave();
}
}
private void spawnNextWave() {
// Grab the wave number.
int nextWave = waveManager.getWaveNumber() + 1;
// Grant rewards (if any) for the wave that just ended
grantRewards(nextWave - 1);

View File

@ -21,6 +21,7 @@ min-players: 0
max-players: 0
max-join-distance: 0
first-wave-delay: 5
next-wave-delay: 0
wave-interval: 15
final-wave: 0
monster-limit: 100