updated InfoBars to use Bukkit scheduler for data container updates; enhanced CoordinateDisplay with Unicode icons and adjusted text styling

This commit is contained in:
2025-10-03 17:38:29 +02:00
parent e49c3b1987
commit 9ee5f6e419
2 changed files with 10 additions and 6 deletions

View File

@@ -59,7 +59,7 @@ public class CoordinateDisplay extends Appliance {
List<Component> components = new ArrayList<>();
if (config.coordinates()) {
components.add(Component.text("XYZ: ", NamedTextColor.GOLD));
components.add(Component.text("\uD83C\uDF0E ", NamedTextColor.GOLD));
components.add(Component.text(String.format(
"%d %d %d",
player.getLocation().getBlockX(),
@@ -70,17 +70,17 @@ public class CoordinateDisplay extends Appliance {
if (config.direction()) {
if (!components.isEmpty()) {
components.add(Component.text(" | ", NamedTextColor.DARK_GRAY));
components.add(Component.text(" | ", NamedTextColor.GRAY));
}
components.add(Component.text("Richtung: ", NamedTextColor.GOLD));
components.add(Component.text("\uD83E\uDDED ", NamedTextColor.GOLD));
components.add(Component.text(DataSizeConverter.getCardinalDirection(player.getLocation())));
}
if (config.time()) {
if (!components.isEmpty()) {
components.add(Component.text(" | ", NamedTextColor.DARK_GRAY));
components.add(Component.text(" | ", NamedTextColor.GRAY));
}
components.add(Component.text("Zeit: ", NamedTextColor.GOLD));
components.add(Component.text(" ", NamedTextColor.GOLD));
components.add(Component.text(WorldUtils.getGameTime(player.getWorld())));
}

View File

@@ -7,6 +7,7 @@ import eu.mhsl.craftattack.spawn.core.appliance.ApplianceCommand;
import eu.mhsl.craftattack.spawn.common.appliances.metaGameplay.infoBars.bars.MsptBar;
import eu.mhsl.craftattack.spawn.common.appliances.metaGameplay.infoBars.bars.PlayerCounterBar;
import eu.mhsl.craftattack.spawn.common.appliances.metaGameplay.infoBars.bars.TpsBar;
import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
@@ -57,7 +58,10 @@ public class InfoBars extends Appliance {
}
private void setEnabledBars(Player player, List<String> bars) {
player.getPersistentDataContainer().set(this.infoBarKey, PersistentDataType.LIST.strings(), bars);
Bukkit.getScheduler().runTask(
Main.instance(),
() -> player.getPersistentDataContainer().set(this.infoBarKey, PersistentDataType.LIST.strings(), bars)
);
}
private Bar getBarByName(String name) {