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