Improves the book list somewhat
All checks were successful
EpicKnarvik97/Books-Without-Borders/pipeline/head This commit looks good

This commit is contained in:
2025-08-02 03:33:44 +02:00
parent 6aa422d461
commit ed0a750eb4

View File

@@ -138,12 +138,17 @@ public final class BookFileHelper {
*/ */
private static void showBookMenu(@NotNull CommandSender sender, @NotNull String command, int page, private static void showBookMenu(@NotNull CommandSender sender, @NotNull String command, int page,
int totalPages, @NotNull List<String> availableBooks) { int totalPages, @NotNull List<String> availableBooks) {
ComponentBuilder headerComponent = new ComponentBuilder();
headerComponent.append("Books page " + page + " of " + totalPages).color(ChatColor.GREEN);
sender.spigot().sendMessage(headerComponent.create());
// Print the previous page button // Print the previous page button
ComponentBuilder previousComponent = new ComponentBuilder(); ComponentBuilder previousComponent = new ComponentBuilder();
if (page > 1) { if (page > 1) {
String fullCommand = "/" + command + " page" + (page - 1);
HoverEvent prevPagePreview = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("To page " + (page - 1))); HoverEvent prevPagePreview = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("To page " + (page - 1)));
ClickEvent prevPageClick = new ClickEvent(ClickEvent.Action.RUN_COMMAND, command + " page" + (page - 1)); ClickEvent prevPageClick = new ClickEvent(ClickEvent.Action.RUN_COMMAND, fullCommand);
previousComponent.append("Previous [<]").event(prevPagePreview).event(prevPageClick); previousComponent.append("Previous [<] " + ChatColor.DARK_GRAY + fullCommand).event(prevPagePreview).event(prevPageClick);
} else { } else {
previousComponent.append("Previous [<]").color(ChatColor.GRAY); previousComponent.append("Previous [<]").color(ChatColor.GRAY);
} }
@@ -169,9 +174,10 @@ public final class BookFileHelper {
// Print the next page button // Print the next page button
ComponentBuilder nextComponent = new ComponentBuilder(); ComponentBuilder nextComponent = new ComponentBuilder();
if (page < totalPages) { if (page < totalPages) {
String fullCommand = "/" + command + " page" + (page + 1);
HoverEvent nextPagePreview = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("To page " + (page + 1))); HoverEvent nextPagePreview = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("To page " + (page + 1)));
ClickEvent nextPageClick = new ClickEvent(ClickEvent.Action.RUN_COMMAND, command + " page" + (page + 1)); ClickEvent nextPageClick = new ClickEvent(ClickEvent.Action.RUN_COMMAND, fullCommand);
nextComponent.append("Next [>]").event(nextPagePreview).event(nextPageClick); nextComponent.append("Next [>] " + ChatColor.DARK_GRAY + fullCommand).event(nextPagePreview).event(nextPageClick);
} else { } else {
nextComponent.append("Next [>]").color(ChatColor.GRAY); nextComponent.append("Next [>]").color(ChatColor.GRAY);
} }