added the next tier thing on the scoreboard of the game

This commit is contained in:
Trixkz 2021-11-25 00:16:06 -05:00
parent 804a665363
commit 3d9d9a4b60
4 changed files with 41 additions and 7 deletions

View File

@ -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<Double, String> 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<Double, String> 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;
}

View File

@ -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);

View File

@ -75,16 +75,19 @@ public class ArenaManager {
CustomLocation locTeamBupgrades = CustomLocation.stringToLocation(teamBupgrades);
List<CustomLocation> teamGeneratorLocations = new ArrayList<>();
for (String location : teamGenerators) {
teamGeneratorLocations.add(CustomLocation.stringToLocation(location));
}
List<CustomLocation> diamondGeneratorLocations = new ArrayList<>();
for (String location : diamondGenerators) {
diamondGeneratorLocations.add(CustomLocation.stringToLocation(location));
}
List<CustomLocation> 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<CustomLocation> copyTeamGeneratorLocations = new ArrayList<>();
for (String location : copyTeamGenerators) {
copyTeamGeneratorLocations.add(CustomLocation.stringToLocation(location));
}
List<CustomLocation> copyDiamondGeneratorLocations = new ArrayList<>();
for (String location : copyDiamondGenerators) {
copyDiamondGeneratorLocations.add(CustomLocation.stringToLocation(location));
}
List<CustomLocation> copyEmeraldGeneratorLocations = new ArrayList<>();
for (String location : copyEmeraldGenerators) {
copyEmeraldGeneratorLocations.add(CustomLocation.stringToLocation(location));
}

View File

@ -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) {