diff --git a/src/main/java/rip/tilly/bedwars/game/Game.java b/src/main/java/rip/tilly/bedwars/game/Game.java index cc1fea6..aa1dee5 100644 --- a/src/main/java/rip/tilly/bedwars/game/Game.java +++ b/src/main/java/rip/tilly/bedwars/game/Game.java @@ -3,6 +3,7 @@ package rip.tilly.bedwars.game; import io.netty.util.internal.ConcurrentSet; import lombok.Getter; import lombok.Setter; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; @@ -16,10 +17,10 @@ import rip.tilly.bedwars.game.arena.Arena; import rip.tilly.bedwars.game.arena.CopiedArena; import rip.tilly.bedwars.generators.Generator; import rip.tilly.bedwars.generators.GeneratorTier; +import rip.tilly.bedwars.generators.GeneratorType; import rip.tilly.bedwars.utils.CC; +import rip.tilly.bedwars.utils.CustomLocation; import rip.tilly.bedwars.utils.TimeUtils; - -import java.awt.*; import java.util.*; import java.util.List; import java.util.stream.Stream; @@ -220,4 +221,62 @@ public class Game { return false; } + + public void tick(int amount) { + if (this.secondsToMinutes(amount) == 5D) { + Bukkit.broadcastMessage(CC.translate("&bDiamond &egenerators have been upgraded to &bTier II")); + + this.diamondGeneratorTier = GeneratorTier.TWO; + } + + if (this.secondsToMinutes(amount) == 8D) { + Bukkit.broadcastMessage(CC.translate("&aEmerald &egenerators have been upgraded to &bTier II")); + + this.emeraldGeneratorTier = GeneratorTier.TWO; + } + + if (this.secondsToMinutes(amount) == 10D) { + Bukkit.broadcastMessage(CC.translate("&bDiamond &egenerators have been upgraded to &bTier II")); + + this.diamondGeneratorTier = GeneratorTier.THREE; + } + + if (this.secondsToMinutes(amount) == 12D) { + Bukkit.broadcastMessage(CC.translate("&aEmerald &egenerators have been upgraded to &bTier II")); + + this.emeraldGeneratorTier = GeneratorTier.THREE; + } + + if (this.secondsToMinutes(amount) == 15D) { + Bukkit.broadcastMessage(CC.translate("&bDiamond &egenerators have been upgraded to &bTier II")); + + this.diamondGeneratorTier = GeneratorTier.FOUR; + } + + for (CustomLocation customLocation : this.arena.getTeamGenerators()) { + Generator ironGenerator = new Generator(customLocation.toBukkitLocation(), GeneratorType.IRON, true, this); + ironGenerator.spawn(); + + Generator goldGenerator = new Generator(customLocation.toBukkitLocation(), GeneratorType.GOLD, true, this); + goldGenerator.spawn(); + } + + for (Generator generator : this.getActivatedGenerators()) { + generator.setActivated(true); + + if (generator.getGeneratorType() == GeneratorType.DIAMOND) { + generator.setGeneratorTier(this.diamondGeneratorTier); + } + + if (generator.getGeneratorType() == GeneratorType.EMERALD) { + generator.setGeneratorTier(this.emeraldGeneratorTier); + } + + generator.spawn(); + } + } + + public double secondsToMinutes(int seconds) { + return seconds / 60D; + } } diff --git a/src/main/java/rip/tilly/bedwars/generators/Generator.java b/src/main/java/rip/tilly/bedwars/generators/Generator.java index 4eee484..8509948 100644 --- a/src/main/java/rip/tilly/bedwars/generators/Generator.java +++ b/src/main/java/rip/tilly/bedwars/generators/Generator.java @@ -259,7 +259,7 @@ public class Generator { return this.generatorType; } - public void setGeneratorTier() { + public void setGeneratorTier(GeneratorTier generatorTier) { this.generatorTier = generatorTier; } } diff --git a/src/main/java/rip/tilly/bedwars/runnables/GameRunnable.java b/src/main/java/rip/tilly/bedwars/runnables/GameRunnable.java index 5bf791c..5181045 100644 --- a/src/main/java/rip/tilly/bedwars/runnables/GameRunnable.java +++ b/src/main/java/rip/tilly/bedwars/runnables/GameRunnable.java @@ -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; } }