From fcbfcf1c9c59530893009f56a963344d6b2d443d Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 7 Aug 2022 18:20:46 +0200 Subject: [PATCH] Fix some numbering stuff for listing --- .../commands/SchematicCommand.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java index 608ad43..f243ebd 100644 --- a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java @@ -84,19 +84,19 @@ public class SchematicCommand extends SWCommand { @Register("list") @Register({"list", "/"}) - public void schemList(Player player, @OptionalValue("0") int page) { - renderSchemlist(player, SchematicNode.getSchematicsAccessibleByUser(getUser(player).getId(), 0), page, null, SchematicListBehavior.DEFAULT); + public void schemList(Player player, @OptionalValue("1") int page) { + renderSchemlist(player, SchematicNode.getSchematicsAccessibleByUser(getUser(player).getId(), 0), Math.max(page - 1, 0), null, SchematicListBehavior.DEFAULT); } @Register({"list", "public"}) - public void schemListPublic(Player player, @Mapper("publicDirMapper") SchematicNode node, @OptionalValue("0") int page) { + public void schemListPublic(Player player, @Mapper("publicDirMapper") SchematicNode node, @OptionalValue("1") int page) { schemList(player, node, page); } @Register({"list", "public"}) @Register({"list", "public", "/"}) - public void schemListPublic(Player player, @OptionalValue("0") int page) { - renderSchemlist(player, SchematicNode.getSchematicsAccessibleByUser(0, 0), page, null, SchematicListBehavior.builder().setPublics(true).setPageCommandGen(integer -> "/schem list public " + integer).build()); + public void schemListPublic(Player player, @OptionalValue("1") int page) { + renderSchemlist(player, SchematicNode.getSchematicsAccessibleByUser(0, 0), Math.max(page - 1, 0), null, SchematicListBehavior.builder().setPublics(true).setPageCommandGen(integer -> "/schem list public " + integer).build()); } @@ -106,12 +106,12 @@ public class SchematicCommand extends SWCommand { } @Register("list") - public void schemList(Player player, @Mapper("dirMapper") SchematicNode node, @OptionalValue("0") int page) { + public void schemList(Player player, @Mapper("dirMapper") SchematicNode node, @OptionalValue("1") int page) { SteamwarUser user = getUser(player); if (!node.isDir()) { SchematicSystem.MESSAGE.send("COMMAND_NOT_FOLDER", player); } else { - renderSchemlist(player, SchematicNode.getSchematicNodeInNode(node), page, node, SchematicListBehavior.builder().setPublics(node.getOwner() == 0).setPageCommandGen(value -> "/schem list " + (node.getOwner()==0?"public ":"") + node.generateBreadcrumbs(user) + " " + value).build()); + renderSchemlist(player, SchematicNode.getSchematicNodeInNode(node), Math.max(page - 1, 0), node, SchematicListBehavior.builder().setPublics(node.getOwner() == 0).setPageCommandGen(value -> "/schem list " + (node.getOwner()==0?"public ":"") + node.generateBreadcrumbs(user) + " " + value).build()); } } @@ -287,7 +287,7 @@ public class SchematicCommand extends SWCommand { } @Register("search") - public void schemSearch(Player player, @OptionalValue("0") int page, @Mapper("searchMapper") String... query) { + public void schemSearch(Player player, @OptionalValue("1") int page, @Mapper("searchMapper") String... query) { SteamwarUser user = getUser(player); int userId = user.getId(); List> predicates = new ArrayList<>(); @@ -349,7 +349,7 @@ public class SchematicCommand extends SWCommand { } return true; }); - renderSchemlist(player, nodes, page, null, SchematicListBehavior.builder().setPublics(userId == 0).setShowPath(false).setRenderHook(s -> { + renderSchemlist(player, nodes, Math.max(page - 1, 0), null, SchematicListBehavior.builder().setPublics(userId == 0).setShowPath(false).setRenderHook(s -> { for (String ss : nameList) { s = s.replace(ss, "§e§l" + ss + "§7"); }