From a83a79c17eb34e77e6001d02af917044edfd4078 Mon Sep 17 00:00:00 2001 From: Traks Date: Thu, 22 Jul 2021 21:53:26 +0200 Subject: [PATCH] Error message for '/p v' when page out of range --- .../com/plotsquared/core/command/Visit.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/command/Visit.java b/Core/src/main/java/com/plotsquared/core/command/Visit.java index c998ba0b8..5e95a6a2c 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Visit.java +++ b/Core/src/main/java/com/plotsquared/core/command/Visit.java @@ -80,11 +80,6 @@ public class Visit extends Command { // then we get it another time further on final List unsorted = query.asList(); - if (unsorted.isEmpty()) { - player.sendMessage(TranslatableCaption.of("invalid.found_no_plots")); - return; - } - if (unsorted.size() > 1) { query.whereBasePlot(); } @@ -93,12 +88,6 @@ public class Visit extends Command { page = 1; } - if (page < 1 || page > unsorted.size()) { - // TODO: Huh? - // MainUtil.sendMessage(player, String.format("(1, %d)", unsorted.size())); - return; - } - PlotArea relativeArea = sortByArea; if (Settings.Teleport.PER_WORLD_VISIT && sortByArea == null) { relativeArea = player.getApplicablePlotArea(); @@ -112,6 +101,18 @@ public class Visit extends Command { final List plots = query.asList(); + if (plots.isEmpty()) { + player.sendMessage(TranslatableCaption.of("invalid.found_no_plots")); + return; + } else if (plots.size() < page || page < 1) { + player.sendMessage( + TranslatableCaption.of("invalid.number_not_in_range"), + Template.of("min", "1"), + Template.of("max", String.valueOf(plots.size())) + ); + return; + } + final Plot plot = plots.get(page - 1); if (!plot.hasOwner()) { if (!Permissions.hasPermission(player, Permission.PERMISSION_VISIT_UNOWNED)) {