updated InfoBars: localized names, dynamic coloring, and progress clamping adjustments
This commit is contained in:
@@ -33,7 +33,7 @@ public abstract class Bar {
|
||||
private BossBar createBar() {
|
||||
return BossBar.bossBar(
|
||||
this.title(),
|
||||
this.correctedProgress(),
|
||||
this.clampedProgress(),
|
||||
this.color(),
|
||||
this.overlay()
|
||||
);
|
||||
@@ -44,7 +44,7 @@ public abstract class Bar {
|
||||
|
||||
this.beforeRefresh();
|
||||
this.bossBar.name(this.title());
|
||||
this.bossBar.progress(this.correctedProgress());
|
||||
this.bossBar.progress(this.clampedProgress());
|
||||
this.bossBar.color(this.color());
|
||||
this.bossBar.overlay(this.overlay());
|
||||
}
|
||||
@@ -53,7 +53,7 @@ public abstract class Bar {
|
||||
this.updateTask.cancel();
|
||||
}
|
||||
|
||||
private float correctedProgress() {
|
||||
private float clampedProgress() {
|
||||
return Math.clamp(this.progress(), 0, 1);
|
||||
}
|
||||
|
||||
|
@@ -17,9 +17,9 @@ public class InfoBarSetting extends MultiBoolSetting<InfoBarSetting.InfoBarConfi
|
||||
}
|
||||
|
||||
public record InfoBarConfiguration(
|
||||
@DisplayName("mspt") boolean mspt,
|
||||
@DisplayName("Player counter") boolean playerCounter,
|
||||
@DisplayName("TPS") boolean tps
|
||||
@DisplayName("Millisekunden pro Tick") boolean mspt,
|
||||
@DisplayName("Spieler online") boolean playerCounter,
|
||||
@DisplayName("Ticks pro Sekunde") boolean tps
|
||||
) {}
|
||||
|
||||
@Override
|
||||
|
@@ -27,10 +27,10 @@ public class MsptBar extends Bar {
|
||||
return Component.text()
|
||||
.append(Component.text("M"))
|
||||
.append(Component.text("illi", NamedTextColor.GRAY))
|
||||
.append(Component.text("S"))
|
||||
.append(Component.text("econds ", NamedTextColor.GRAY))
|
||||
.append(Component.text("P"))
|
||||
.append(Component.text("er ", NamedTextColor.GRAY))
|
||||
.append(Component.text("s"))
|
||||
.append(Component.text("ekunden ", NamedTextColor.GRAY))
|
||||
.append(Component.text("p"))
|
||||
.append(Component.text("ro ", NamedTextColor.GRAY))
|
||||
.append(Component.text("T"))
|
||||
.append(Component.text("ick", NamedTextColor.GRAY))
|
||||
.append(Component.text(": "))
|
||||
@@ -45,7 +45,7 @@ public class MsptBar extends Bar {
|
||||
|
||||
@Override
|
||||
protected BossBar.Color color() {
|
||||
return BossBar.Color.BLUE;
|
||||
return this.currentMSPT() <= 50 ? BossBar.Color.GREEN : BossBar.Color.RED;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -40,7 +40,10 @@ public class PlayerCounterBar extends Bar {
|
||||
|
||||
@Override
|
||||
protected BossBar.Color color() {
|
||||
return BossBar.Color.BLUE;
|
||||
int freeSlots = this.getMaxPlayerCount() - this.getCurrentPlayerCount();
|
||||
return freeSlots <= 0
|
||||
? BossBar.Color.RED
|
||||
: freeSlots < 5 ? BossBar.Color.YELLOW : BossBar.Color.GREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -27,10 +27,10 @@ public class TpsBar extends Bar {
|
||||
return Component.text()
|
||||
.append(Component.text("T"))
|
||||
.append(Component.text("icks ", NamedTextColor.GRAY))
|
||||
.append(Component.text("P"))
|
||||
.append(Component.text("er ", NamedTextColor.GRAY))
|
||||
.append(Component.text("p"))
|
||||
.append(Component.text("ro ", NamedTextColor.GRAY))
|
||||
.append(Component.text("S"))
|
||||
.append(Component.text("econds", NamedTextColor.GRAY))
|
||||
.append(Component.text("ekunde", NamedTextColor.GRAY))
|
||||
.append(Component.text(": "))
|
||||
.append(Component.text(String.format("%.2f", this.currentTps()), ColorUtil.tpsColor(this.currentTps())))
|
||||
.build();
|
||||
@@ -43,7 +43,9 @@ public class TpsBar extends Bar {
|
||||
|
||||
@Override
|
||||
protected BossBar.Color color() {
|
||||
return BossBar.Color.BLUE;
|
||||
return this.currentTps() >= 18
|
||||
? BossBar.Color.GREEN
|
||||
: this.currentTps() >= 15 ? BossBar.Color.YELLOW : BossBar.Color.RED;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user