Error message for '/p v' when page out of range

This commit is contained in:
Traks 2021-07-22 21:53:26 +02:00 committed by dordsor21
parent 8a77d5a450
commit a83a79c17e

View File

@ -80,11 +80,6 @@ public class Visit extends Command {
// then we get it another time further on
final List<Plot> 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<Plot> 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)) {