Tab list phase configurable

This commit is contained in:
Alessandro Proto 2024-10-26 09:54:33 +02:00
parent 74bc5fd995
commit 2f3b5fcbc2
2 changed files with 32 additions and 26 deletions

View file

@ -21,6 +21,8 @@ public class RccServerConfigModel {
public int teleportRequestTimeout = 120;
public boolean enableTabList = true;
public int tabListTickDelay = 2;
public double tabPhaseFrequency = 40;
public ArrayList<String> tabHeader = new ArrayList<>(List.of(
"<gradient:#DEDE6C:#CC4C4C:{phase}><st> </st></gradient>"
));

View file

@ -13,10 +13,13 @@ public class TabList {
if (!RccServer.CONFIG.enableTabList())
return;
ServerTickEvents.END_SERVER_TICK.register(server -> {
var phase = (Math.sin((server.getTicks() * Math.PI) / 20) + 1) / 2d;
var minimessage = MiniMessage.miniMessage();
ServerTickEvents.END_SERVER_TICK.register(server -> {
if(server.getTicks() % RccServer.CONFIG.tabListTickDelay() == 0) {
var phase = (Math.sin((server.getTicks() * Math.PI * 2) / RccServer.CONFIG.tabPhaseFrequency()) + 1) / 2d;
server.getPlayerManager().getPlayerList().forEach(player -> {
var playerContext = PlaceholderContext.of(player);
Component headerComponent = Component.empty();
@ -47,6 +50,7 @@ public class TabList {
var audience = RccServer.getInstance().adventure().player(player.getUuid());
audience.sendPlayerListHeaderAndFooter(parsedHeader, parsedFooter);
});
}
});
}