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 rip.tilly.bedwars.utils.TimeUtils;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@Getter @Getter
@ -271,6 +272,9 @@ public class Game {
Generator goldGenerator = new Generator(customLocation.toBukkitLocation(), GeneratorType.GOLD, true, this); Generator goldGenerator = new Generator(customLocation.toBukkitLocation(), GeneratorType.GOLD, true, this);
goldGenerator.spawn(); goldGenerator.spawn();
Generator emeraldGenerator = new Generator(customLocation.toBukkitLocation(), GeneratorType.EMERALD, true, this);
emeraldGenerator.spawn();
} }
for (Generator generator : this.getActivatedGenerators()) { 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) { public double secondsToMinutes(int seconds) {
return seconds / 60D; return seconds / 60D;
} }

View File

@ -62,7 +62,7 @@ public class Generator {
this.generatorTypeArmorStand.setCustomNameVisible(true); this.generatorTypeArmorStand.setCustomNameVisible(true);
this.generatorTypeArmorStand.setCustomName(CC.translate(this.getArmorStandName())); this.generatorTypeArmorStand.setCustomName(CC.translate(this.getArmorStandName()));
this.generatorTierArmorStand.setCustomNameVisible(true); 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()) { if (this.secondsSinceActivation < this.getActivationTime()) {
@ -128,20 +128,21 @@ public class Generator {
return; return;
} }
Material generatorTypeMaterial; Material generatorMaterial;
if (this.generatorType == GeneratorType.DIAMOND) { if (this.generatorType == GeneratorType.DIAMOND) {
generatorTypeMaterial = Material.DIAMOND_BLOCK; generatorMaterial = Material.DIAMOND_BLOCK;
} else if (this.generatorType == GeneratorType.EMERALD) { } else if (this.generatorType == GeneratorType.EMERALD) {
generatorTypeMaterial = Material.EMERALD_BLOCK; generatorMaterial = Material.EMERALD_BLOCK;
} else { } 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 = this.location.getWorld().spawn(this.location.clone().add(0.0D, 0.5D, 0.0D), ArmorStand.class);
this.indictatorArmorStand.setVisible(false); this.indictatorArmorStand.setVisible(false);
this.indictatorArmorStand.setOp(true); this.indictatorArmorStand.setOp(true);
this.indictatorArmorStand.setGravity(false); 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 = this.location.getWorld().spawn(this.location.clone().add(0.0D, 1.0D, 0.0D), ArmorStand.class);
this.generatorTypeArmorStand.setVisible(false); this.generatorTypeArmorStand.setVisible(false);
this.generatorTypeArmorStand.setOp(true); this.generatorTypeArmorStand.setOp(true);

View File

@ -75,16 +75,19 @@ public class ArenaManager {
CustomLocation locTeamBupgrades = CustomLocation.stringToLocation(teamBupgrades); CustomLocation locTeamBupgrades = CustomLocation.stringToLocation(teamBupgrades);
List<CustomLocation> teamGeneratorLocations = new ArrayList<>(); List<CustomLocation> teamGeneratorLocations = new ArrayList<>();
for (String location : teamGenerators) { for (String location : teamGenerators) {
teamGeneratorLocations.add(CustomLocation.stringToLocation(location)); teamGeneratorLocations.add(CustomLocation.stringToLocation(location));
} }
List<CustomLocation> diamondGeneratorLocations = new ArrayList<>(); List<CustomLocation> diamondGeneratorLocations = new ArrayList<>();
for (String location : diamondGenerators) { for (String location : diamondGenerators) {
diamondGeneratorLocations.add(CustomLocation.stringToLocation(location)); diamondGeneratorLocations.add(CustomLocation.stringToLocation(location));
} }
List<CustomLocation> emeraldGeneratorLocations = new ArrayList<>(); List<CustomLocation> emeraldGeneratorLocations = new ArrayList<>();
for (String location : emeraldGenerators) { for (String location : emeraldGenerators) {
emeraldGeneratorLocations.add(CustomLocation.stringToLocation(location)); emeraldGeneratorLocations.add(CustomLocation.stringToLocation(location));
} }
@ -126,16 +129,19 @@ public class ArenaManager {
CustomLocation copyLocTeamBupgrades = CustomLocation.stringToLocation(copyTeamBupgrades); CustomLocation copyLocTeamBupgrades = CustomLocation.stringToLocation(copyTeamBupgrades);
List<CustomLocation> copyTeamGeneratorLocations = new ArrayList<>(); List<CustomLocation> copyTeamGeneratorLocations = new ArrayList<>();
for (String location : copyTeamGenerators) { for (String location : copyTeamGenerators) {
copyTeamGeneratorLocations.add(CustomLocation.stringToLocation(location)); copyTeamGeneratorLocations.add(CustomLocation.stringToLocation(location));
} }
List<CustomLocation> copyDiamondGeneratorLocations = new ArrayList<>(); List<CustomLocation> copyDiamondGeneratorLocations = new ArrayList<>();
for (String location : copyDiamondGenerators) { for (String location : copyDiamondGenerators) {
copyDiamondGeneratorLocations.add(CustomLocation.stringToLocation(location)); copyDiamondGeneratorLocations.add(CustomLocation.stringToLocation(location));
} }
List<CustomLocation> copyEmeraldGeneratorLocations = new ArrayList<>(); List<CustomLocation> copyEmeraldGeneratorLocations = new ArrayList<>();
for (String location : copyEmeraldGenerators) { for (String location : copyEmeraldGenerators) {
copyEmeraldGeneratorLocations.add(CustomLocation.stringToLocation(location)); copyEmeraldGeneratorLocations.add(CustomLocation.stringToLocation(location));
} }

View File

@ -218,7 +218,9 @@ public class ScoreboardProvider implements BoardAdapter {
lines.add(CC.scoreboardBar); lines.add(CC.scoreboardBar);
lines.add("&fDuration: &d" + game.getDuration()); lines.add("&fDuration: &d" + game.getDuration());
lines.add(" "); lines.add("");
lines.add(game.getNextTierString(game.getDurationTimer()));
lines.add("");
if (yourTeam.isHasBed()) { if (yourTeam.isHasBed()) {
lines.add("&7[" + yourTeam.getPlayerTeam().getChatColor() + yourTeam.getPlayerTeam().getSmallName() + "&7] &a&l✓ &7(You)"); lines.add("&7[" + yourTeam.getPlayerTeam().getChatColor() + yourTeam.getPlayerTeam().getSmallName() + "&7] &a&l✓ &7(You)");
} else if (yourTeam.getPlayingPlayers().size() > 0) { } else if (yourTeam.getPlayingPlayers().size() > 0) {