This commit is contained in:
Trixkz
2021-11-23 09:26:06 -05:00
parent 6a88523d78
commit 4f2702331e
3 changed files with 76 additions and 7 deletions

View File

@ -1,6 +1,5 @@
package rip.tilly.bedwars.runnables;
import lombok.RequiredArgsConstructor;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.scheduler.BukkitRunnable;
@ -8,11 +7,17 @@ import rip.tilly.bedwars.BedWars;
import rip.tilly.bedwars.game.Game;
import rip.tilly.bedwars.game.GameState;
@RequiredArgsConstructor
public class GameRunnable extends BukkitRunnable {
private final BedWars plugin = BedWars.getInstance();
private final Game game;
private BedWars plugin = BedWars.getInstance();
private Game game;
private int amount;
public GameRunnable(Game game) {
this.game = game;
}
@Override
public void run() {
@ -25,9 +30,13 @@ public class GameRunnable extends BukkitRunnable {
this.game.broadcastWithSound("&eStarting match in &d" + this.game.getCountdown() + " &eseconds...", Sound.NOTE_PLING);
this.game.broadcastTitle("&d&lStarting Match In...", "&e" + this.game.getCountdown());
}
break;
case FIGHTING:
this.amount++;
this.game.incrementDuration();
this.game.tick(this.amount);
break;
case ENDING:
if (this.game.decrementCountdown() == 0) {
@ -45,6 +54,7 @@ public class GameRunnable extends BukkitRunnable {
this.plugin.getGameManager().removeGame(this.game);
this.cancel();
}
break;
}
}