diff --git a/src/main/java/rip/tilly/bedwars/game/Game.java b/src/main/java/rip/tilly/bedwars/game/Game.java index ea6c40f..aee2e6f 100644 --- a/src/main/java/rip/tilly/bedwars/game/Game.java +++ b/src/main/java/rip/tilly/bedwars/game/Game.java @@ -25,6 +25,7 @@ import rip.tilly.bedwars.utils.LocationUtils; import rip.tilly.bedwars.utils.TimeUtils; import java.util.*; +import java.util.stream.Collectors; import java.util.stream.Stream; @Getter @@ -271,6 +272,9 @@ public class Game { Generator goldGenerator = new Generator(customLocation.toBukkitLocation(), GeneratorType.GOLD, true, this); goldGenerator.spawn(); + + Generator emeraldGenerator = new Generator(customLocation.toBukkitLocation(), GeneratorType.EMERALD, true, this); + emeraldGenerator.spawn(); } for (Generator generator : this.getActivatedGenerators()) { @@ -288,6 +292,27 @@ public class Game { } } + public String getNextTierString(int amount) { + Map toCalculate = new HashMap<>(); + toCalculate.put(5D, "Diamond II"); + toCalculate.put(8D, "Emerald II"); + toCalculate.put(10D, "Diamond III"); + toCalculate.put(12D, "Emerald III"); + toCalculate.put(15D, "Diamond IV"); + + for (Map.Entry entry : toCalculate.entrySet().stream().sorted(Comparator.comparingInt(key -> (key.getKey()).intValue())).collect(Collectors.toList())) { + if (secondsToMinutes(amount) < entry.getKey()) { + int difference = (entry.getKey()).intValue() * 60 - amount; + int minutesLeft = difference % 3600 / 60; + int secondsLeft = difference % 60; + + return entry.getValue() + ": " + String.format("%02d:%02d", minutesLeft, secondsLeft); + } + } + + return null; + } + 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 b8abf2a..23a078a 100644 --- a/src/main/java/rip/tilly/bedwars/generators/Generator.java +++ b/src/main/java/rip/tilly/bedwars/generators/Generator.java @@ -62,7 +62,7 @@ public class Generator { this.generatorTypeArmorStand.setCustomNameVisible(true); this.generatorTypeArmorStand.setCustomName(CC.translate(this.getArmorStandName())); this.generatorTierArmorStand.setCustomNameVisible(true); - this.generatorTierArmorStand.setCustomName(CC.translate("&fTier: &b" + this.generatorTier.getFormattedName())); + this.generatorTierArmorStand.setCustomName(CC.translate("&fTier: &c" + this.generatorTier.getFormattedName())); } if (this.secondsSinceActivation < this.getActivationTime()) { @@ -128,20 +128,21 @@ public class Generator { return; } - Material generatorTypeMaterial; + Material generatorMaterial; + if (this.generatorType == GeneratorType.DIAMOND) { - generatorTypeMaterial = Material.DIAMOND_BLOCK; + generatorMaterial = Material.DIAMOND_BLOCK; } else if (this.generatorType == GeneratorType.EMERALD) { - generatorTypeMaterial = Material.EMERALD_BLOCK; + generatorMaterial = Material.EMERALD_BLOCK; } else { - generatorTypeMaterial = Material.STONE; + generatorMaterial = Material.STONE; } this.indictatorArmorStand = this.location.getWorld().spawn(this.location.clone().add(0.0D, 0.5D, 0.0D), ArmorStand.class); this.indictatorArmorStand.setVisible(false); this.indictatorArmorStand.setOp(true); this.indictatorArmorStand.setGravity(false); - this.indictatorArmorStand.getEquipment().setHelmet(new ItemStack(generatorTypeMaterial)); + this.indictatorArmorStand.getEquipment().setHelmet(new ItemStack(generatorMaterial)); this.generatorTypeArmorStand = this.location.getWorld().spawn(this.location.clone().add(0.0D, 1.0D, 0.0D), ArmorStand.class); this.generatorTypeArmorStand.setVisible(false); this.generatorTypeArmorStand.setOp(true); diff --git a/src/main/java/rip/tilly/bedwars/managers/arena/ArenaManager.java b/src/main/java/rip/tilly/bedwars/managers/arena/ArenaManager.java index 734ec0e..acbc25a 100644 --- a/src/main/java/rip/tilly/bedwars/managers/arena/ArenaManager.java +++ b/src/main/java/rip/tilly/bedwars/managers/arena/ArenaManager.java @@ -75,16 +75,19 @@ public class ArenaManager { CustomLocation locTeamBupgrades = CustomLocation.stringToLocation(teamBupgrades); List teamGeneratorLocations = new ArrayList<>(); + for (String location : teamGenerators) { teamGeneratorLocations.add(CustomLocation.stringToLocation(location)); } List diamondGeneratorLocations = new ArrayList<>(); + for (String location : diamondGenerators) { diamondGeneratorLocations.add(CustomLocation.stringToLocation(location)); } List emeraldGeneratorLocations = new ArrayList<>(); + for (String location : emeraldGenerators) { emeraldGeneratorLocations.add(CustomLocation.stringToLocation(location)); } @@ -126,16 +129,19 @@ public class ArenaManager { CustomLocation copyLocTeamBupgrades = CustomLocation.stringToLocation(copyTeamBupgrades); List copyTeamGeneratorLocations = new ArrayList<>(); + for (String location : copyTeamGenerators) { copyTeamGeneratorLocations.add(CustomLocation.stringToLocation(location)); } List copyDiamondGeneratorLocations = new ArrayList<>(); + for (String location : copyDiamondGenerators) { copyDiamondGeneratorLocations.add(CustomLocation.stringToLocation(location)); } List copyEmeraldGeneratorLocations = new ArrayList<>(); + for (String location : copyEmeraldGenerators) { copyEmeraldGeneratorLocations.add(CustomLocation.stringToLocation(location)); } diff --git a/src/main/java/rip/tilly/bedwars/providers/scoreboard/ScoreboardProvider.java b/src/main/java/rip/tilly/bedwars/providers/scoreboard/ScoreboardProvider.java index 20247ba..a9bdbcf 100644 --- a/src/main/java/rip/tilly/bedwars/providers/scoreboard/ScoreboardProvider.java +++ b/src/main/java/rip/tilly/bedwars/providers/scoreboard/ScoreboardProvider.java @@ -218,7 +218,9 @@ public class ScoreboardProvider implements BoardAdapter { lines.add(CC.scoreboardBar); lines.add("&fDuration: &d" + game.getDuration()); - lines.add(" "); + lines.add(""); + lines.add(game.getNextTierString(game.getDurationTimer())); + lines.add(""); if (yourTeam.isHasBed()) { lines.add("&7[" + yourTeam.getPlayerTeam().getChatColor() + yourTeam.getPlayerTeam().getSmallName() + "&7] &a&l✓ &7(You)"); } else if (yourTeam.getPlayingPlayers().size() > 0) {