Fixing code duplication
Signed-off-by: Chaoscaot <chaoscaot444@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
8f26a96baa
Commit
b7ad176e51
@ -80,39 +80,27 @@ public class Loadtimer implements Listener {
|
||||
String sec = new DecimalFormat("#.#").format(timeSec);
|
||||
AtomicInteger tnt = new AtomicInteger();
|
||||
tntPlaced.forEach((player, integer) -> tnt.addAndGet(integer));
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
if (Region.getRegion(player.getLocation()).equals(region)) {
|
||||
BossBar bar = getOrDefault(player);
|
||||
bar.setTitle(BauSystem.MESSAGE.parse("LOADTIMER_BOSSBAR", player, timeSinceStart, timeSinceHalf, sec, tnt));
|
||||
bar.setProgress((timeSinceStart % 20d) / 20);
|
||||
bar.setColor(BarColor.GREEN);
|
||||
bar.setStyle(BarStyle.SEGMENTED_20);
|
||||
}
|
||||
});
|
||||
sendBarToRegion(BarStyle.SEGMENTED_20, "LOADTIMER_BOSSBAR", BarColor.GREEN, (timeSinceStart % 20d) / 20, timeSinceStart, timeSinceHalf, sec, tnt);
|
||||
} else if (stage == Stage.WAITING) {
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
if (Region.getRegion(player.getLocation()).equals(region)) {
|
||||
BossBar bar = getOrDefault(player);
|
||||
bar.setStyle(BarStyle.SOLID);
|
||||
bar.setTitle(BauSystem.MESSAGE.parse("LOADTIMER_WAITING", player));
|
||||
bar.setColor(BarColor.GREEN);
|
||||
bar.setProgress(1);
|
||||
}
|
||||
});
|
||||
sendBarToRegion(BarStyle.SOLID, "LOADTIMER_WAITING", BarColor.GREEN, 1);
|
||||
} else if (stage == Stage.ACTIVATED || stage == Stage.IGNITION) {
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
if (Region.getRegion(player.getLocation()).equals(region)) {
|
||||
BossBar bar = getOrDefault(player);
|
||||
bar.setStyle(BarStyle.SOLID);
|
||||
bar.setTitle(BauSystem.MESSAGE.parse(stage == Stage.ACTIVATED ? "LOADTIMER_ACTIVATED" : "LOADTIMER_IGNITION", player));
|
||||
bar.setColor(BarColor.YELLOW);
|
||||
bar.setProgress(1);
|
||||
}
|
||||
});
|
||||
sendBarToRegion(BarStyle.SOLID, stage == Stage.ACTIVATED ? "LOADTIMER_ACTIVATED" : "LOADTIMER_IGNITION", BarColor.YELLOW, 1);
|
||||
}
|
||||
}, 1, 1);
|
||||
}
|
||||
|
||||
private void sendBarToRegion(BarStyle style, String message, BarColor color, double progress, Object... objects) {
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
if (Region.getRegion(player.getLocation()).equals(region)) {
|
||||
BossBar bar = getOrDefault(player);
|
||||
bar.setStyle(style);
|
||||
bar.setTitle(BauSystem.MESSAGE.parse(message, player, objects));
|
||||
bar.setColor(color);
|
||||
bar.setProgress(progress);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean hasTimer(Region r) {
|
||||
return timers.containsKey(r);
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren