From da76d0ac120e5c8cc19be6dc0a4c74e86ba5aeb5 Mon Sep 17 00:00:00 2001 From: Josh Date: Tue, 10 Sep 2019 21:54:18 -0400 Subject: [PATCH] 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 --- .../projectkorra/command/PresetCommand.java | 66 ++++++++++--------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/src/com/projectkorra/projectkorra/command/PresetCommand.java b/src/com/projectkorra/projectkorra/command/PresetCommand.java index efa04582..97708f6e 100644 --- a/src/com/projectkorra/projectkorra/command/PresetCommand.java +++ b/src/com/projectkorra/projectkorra/command/PresetCommand.java @@ -77,41 +77,45 @@ public class PresetCommand extends PKCommand { bPlayer = BendingPlayer.getBendingPlayer(player); } - // bending preset list. - if (args.size() == 1) { - if (Arrays.asList(listaliases).contains(args.get(0)) && this.hasPermission(sender, "list")) { - boolean firstMessage = true; - - final List presets = Preset.presets.get(player.getUniqueId()); - final List presetNames = new ArrayList(); - - if (presets == null || presets.isEmpty()) { - GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.noPresets); - return; - } - - for (final Preset preset : presets) { - presetNames.add(preset.getName()); - } - - for (final String s : this.getPage(presetNames, ChatColor.GOLD + "Presets: ", 1, false)) { - if (firstMessage) { - GeneralMethods.sendBrandingMessage(sender, s); - firstMessage = false; - } else { - sender.sendMessage(ChatColor.YELLOW + s); - } - } - - return; + 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 { - this.help(sender, false); - return; + name = args.get(1); } } - final String name = args.get(1); - if (Arrays.asList(deletealiases).contains(args.get(0)) && this.hasPermission(sender, "delete")) { // bending preset delete name. + // bending preset list. + if (Arrays.asList(listaliases).contains(args.get(0)) && this.hasPermission(sender, "list")) { + boolean firstMessage = true; + + final List presets = Preset.presets.get(player.getUniqueId()); + final List presetNames = new ArrayList(); + + if (presets == null || presets.isEmpty()) { + GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.noPresets); + return; + } + + for (final Preset preset : presets) { + presetNames.add(preset.getName()); + } + + for (final String s : this.getPage(presetNames, ChatColor.GOLD + "Presets: ", page, false)) { + if (firstMessage) { + GeneralMethods.sendBrandingMessage(sender, s); + firstMessage = false; + } else { + sender.sendMessage(ChatColor.YELLOW + s); + } + } + + return; + } 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;