Improves the book list somewhat
All checks were successful
EpicKnarvik97/Books-Without-Borders/pipeline/head This commit looks good
All checks were successful
EpicKnarvik97/Books-Without-Borders/pipeline/head This commit looks good
This commit is contained in:
@@ -138,12 +138,17 @@ public final class BookFileHelper {
|
||||
*/
|
||||
private static void showBookMenu(@NotNull CommandSender sender, @NotNull String command, int page,
|
||||
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
|
||||
ComponentBuilder previousComponent = new ComponentBuilder();
|
||||
if (page > 1) {
|
||||
String fullCommand = "/" + command + " 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));
|
||||
previousComponent.append("Previous [<]").event(prevPagePreview).event(prevPageClick);
|
||||
ClickEvent prevPageClick = new ClickEvent(ClickEvent.Action.RUN_COMMAND, fullCommand);
|
||||
previousComponent.append("Previous [<] " + ChatColor.DARK_GRAY + fullCommand).event(prevPagePreview).event(prevPageClick);
|
||||
} else {
|
||||
previousComponent.append("Previous [<]").color(ChatColor.GRAY);
|
||||
}
|
||||
@@ -169,9 +174,10 @@ public final class BookFileHelper {
|
||||
// Print the next page button
|
||||
ComponentBuilder nextComponent = new ComponentBuilder();
|
||||
if (page < totalPages) {
|
||||
String fullCommand = "/" + command + " 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));
|
||||
nextComponent.append("Next [>]").event(nextPagePreview).event(nextPageClick);
|
||||
ClickEvent nextPageClick = new ClickEvent(ClickEvent.Action.RUN_COMMAND, fullCommand);
|
||||
nextComponent.append("Next [>] " + ChatColor.DARK_GRAY + fullCommand).event(nextPagePreview).event(nextPageClick);
|
||||
} else {
|
||||
nextComponent.append("Next [>]").color(ChatColor.GRAY);
|
||||
}
|
||||
|
Reference in New Issue
Block a user