Fix Preset command not being able to list page numbers higher than 1 (#1024)

## Fixes
* Fixes listing preset pages. Previously doing "/b preset list 2" would just return the help message
This commit is contained in:
Josh 2019-09-10 21:54:18 -04:00 committed by Christopher Martin
parent 2091e58c35
commit da76d0ac12

View file

@ -77,8 +77,19 @@ public class PresetCommand extends PKCommand {
bPlayer = BendingPlayer.getBendingPlayer(player);
}
int page = 1;
String name = null;
if (args.size() == 1 && !Arrays.asList(listaliases).contains(args.get(0))){
this.help(sender, false);
} else if (args.size() >= 2) {
if (Arrays.asList(listaliases).contains(args.get(0))) {
page = Integer.parseInt(args.get(1));
} else {
name = args.get(1);
}
}
// bending preset list.
if (args.size() == 1) {
if (Arrays.asList(listaliases).contains(args.get(0)) && this.hasPermission(sender, "list")) {
boolean firstMessage = true;
@ -94,7 +105,7 @@ public class PresetCommand extends PKCommand {
presetNames.add(preset.getName());
}
for (final String s : this.getPage(presetNames, ChatColor.GOLD + "Presets: ", 1, false)) {
for (final String s : this.getPage(presetNames, ChatColor.GOLD + "Presets: ", page, false)) {
if (firstMessage) {
GeneralMethods.sendBrandingMessage(sender, s);
firstMessage = false;
@ -104,14 +115,7 @@ public class PresetCommand extends PKCommand {
}
return;
} else {
this.help(sender, false);
return;
}
}
final String name = args.get(1);
if (Arrays.asList(deletealiases).contains(args.get(0)) && this.hasPermission(sender, "delete")) { // bending preset delete name.
} else if (Arrays.asList(deletealiases).contains(args.get(0)) && this.hasPermission(sender, "delete")) { // bending preset delete name.
if (!Preset.presetExists(player, name)) {
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.noPresetName);
return;