diff --git a/Pagination/src/main/java/fr/altarik/toolbox/pagination/PaginatedContent.java b/Pagination/src/main/java/fr/altarik/toolbox/pagination/PaginatedContent.java index 706605f..e7034c5 100644 --- a/Pagination/src/main/java/fr/altarik/toolbox/pagination/PaginatedContent.java +++ b/Pagination/src/main/java/fr/altarik/toolbox/pagination/PaginatedContent.java @@ -32,18 +32,20 @@ public class PaginatedContent { List currentPage = new ArrayList<>(); for(String elem : secondSplit) { line++; - currentPage.add(elem); + if(!elem.isEmpty()) + currentPage.add(elem); if(line == 8 || elem.isEmpty()) { pages.add(new Page(currentPage)); line = 0; currentPage = new ArrayList<>(); } } + pages.add(new Page(currentPage)); } public void display(ServerPlayerEntity playerEntity, int page) { if(page >= this.pages.size()) { - throw new IllegalArgumentException("There's " + this.pages.size() + " paginated pages but you wanted page n°" + page); + throw new IllegalArgumentException("There's " + this.pages.size() + " paginated pages but you wanted page n°" + (page + 1)); } else if(page < 0) { throw new IllegalArgumentException("argument page is lower than 0"); } else { diff --git a/Pagination/src/main/java/fr/altarik/toolbox/pagination/command/CommandsRegister.java b/Pagination/src/main/java/fr/altarik/toolbox/pagination/command/CommandsRegister.java index fa01f2e..8c32487 100644 --- a/Pagination/src/main/java/fr/altarik/toolbox/pagination/command/CommandsRegister.java +++ b/Pagination/src/main/java/fr/altarik/toolbox/pagination/command/CommandsRegister.java @@ -26,10 +26,36 @@ public class CommandsRegister { .then(argument("page", IntegerArgumentType.integer()) .executes(this::selectPageCommand) ) + ).then(literal("test") + .requires(source -> source.isExecutedByPlayer() && source.hasPermissionLevel(3)) + .executes(this::testPageCommand) ) ); } + /** + * Simply a debug command + */ + private int testPageCommand(CommandContext context) { + api.createTable(context.getSource().getPlayer(), """ + first line + Second line + + second page + dqdq + dqdqd + qdqdq + dqdq + dqdq + dqdq + dqdqd + third page + dqdqd + dqdqd + d""", "My header"); + return 0; + } + private int selectPageCommand(CommandContext context) throws CommandSyntaxException { try { int page = IntegerArgumentType.getInteger(context, "page");