diff --git a/src/main/java/net/william278/velocitab/config/Settings.java b/src/main/java/net/william278/velocitab/config/Settings.java index 4fc37a3..17789ec 100644 --- a/src/main/java/net/william278/velocitab/config/Settings.java +++ b/src/main/java/net/william278/velocitab/config/Settings.java @@ -21,10 +21,12 @@ import java.util.Map; public class Settings { @YamlKey("headers") - private Map headers = Map.of("default", "&rainbow&Running Velocitab by William278"); + @YamlComment("Header(s) to display above the TAB list for each server group.\nList multiple headers and set update_rate to the number of ticks between frames for basic animations") + private Map> headers = Map.of("default", List.of("&rainbow&Running Velocitab by William278")); @YamlKey("footers") - private Map footers = Map.of("default", "[There are currently %players_online%/%max_players_online% players online](gray)"); + @YamlComment("Footer(s) to display below the TAB list for each server group, same as headers.") + private Map> footers = Map.of("default", List.of("[There are currently %players_online%/%max_players_online% players online](gray)")); @YamlKey("formats") private Map formats = Map.of("default", "&7[%server%] &f%prefix%%username%"); @@ -78,15 +80,23 @@ public class Settings { } @NotNull - public String getHeader(@NotNull String serverGroup) { + public String getHeader(@NotNull String serverGroup, @NotNull int index) { return StringEscapeUtils.unescapeJava( - headers.getOrDefault(serverGroup, "")); + headers.getOrDefault(serverGroup, List.of("")).get(index)); } @NotNull - public String getFooter(@NotNull String serverGroup) { + public String getFooter(@NotNull String serverGroup, @NotNull int index) { return StringEscapeUtils.unescapeJava( - footers.getOrDefault(serverGroup, "")); + footers.getOrDefault(serverGroup, List.of("")).get(index)); + } + + public int getHeaderListSize(@NotNull String serverGroup) { + return headers.getOrDefault(serverGroup, List.of("")).size(); + } + + public int getFooterListSize(@NotNull String serverGroup) { + return footers.getOrDefault(serverGroup, List.of("")).size(); } @NotNull diff --git a/src/main/java/net/william278/velocitab/tab/PlayerTabList.java b/src/main/java/net/william278/velocitab/tab/PlayerTabList.java index b8fa061..796529b 100644 --- a/src/main/java/net/william278/velocitab/tab/PlayerTabList.java +++ b/src/main/java/net/william278/velocitab/tab/PlayerTabList.java @@ -26,6 +26,8 @@ public class PlayerTabList { private final Velocitab plugin; private final ConcurrentLinkedQueue players; private final ConcurrentLinkedQueue fallbackServers; + private int headerIndex = 0; + private int footerIndex = 0; public PlayerTabList(@NotNull Velocitab plugin) { this.plugin = plugin; @@ -159,16 +161,26 @@ public class PlayerTabList { } public CompletableFuture getHeader(@NotNull TabPlayer player) { - return Placeholder.replace(plugin.getSettings().getHeader( - plugin.getSettings().getServerGroup(player.getServerName())), plugin, player) + if (headerIndex >= plugin.getSettings().getHeaderListSize(plugin.getSettings().getServerGroup(player.getServerName()))){ + headerIndex = 0; + } + CompletableFuture headerComponent = Placeholder.replace(plugin.getSettings().getHeader( + plugin.getSettings().getServerGroup(player.getServerName()), headerIndex), plugin, player) .thenApply(header -> plugin.getFormatter().format(header, player, plugin)); + headerIndex++; + return headerComponent; } public CompletableFuture getFooter(@NotNull TabPlayer player) { - return Placeholder.replace(plugin.getSettings().getFooter( - plugin.getSettings().getServerGroup(player.getServerName())), plugin, player) + if (footerIndex >= plugin.getSettings().getFooterListSize(plugin.getSettings().getServerGroup(player.getServerName()))){ + footerIndex = 0; + } + CompletableFuture footerComponent = Placeholder.replace(plugin.getSettings().getFooter( + plugin.getSettings().getServerGroup(player.getServerName()), footerIndex), plugin, player) .thenApply(footer -> plugin.getFormatter().format(footer, player, plugin)); + footerIndex++; + return footerComponent; }