mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-11-01 01:42:18 +00:00
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:
parent
2091e58c35
commit
da76d0ac12
|
@ -77,41 +77,45 @@ public class PresetCommand extends PKCommand {
|
||||||
bPlayer = BendingPlayer.getBendingPlayer(player);
|
bPlayer = BendingPlayer.getBendingPlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
// bending preset list.
|
int page = 1;
|
||||||
if (args.size() == 1) {
|
String name = null;
|
||||||
if (Arrays.asList(listaliases).contains(args.get(0)) && this.hasPermission(sender, "list")) {
|
if (args.size() == 1 && !Arrays.asList(listaliases).contains(args.get(0))){
|
||||||
boolean firstMessage = true;
|
this.help(sender, false);
|
||||||
|
} else if (args.size() >= 2) {
|
||||||
final List<Preset> presets = Preset.presets.get(player.getUniqueId());
|
if (Arrays.asList(listaliases).contains(args.get(0))) {
|
||||||
final List<String> presetNames = new ArrayList<String>();
|
page = Integer.parseInt(args.get(1));
|
||||||
|
|
||||||
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;
|
|
||||||
} else {
|
} else {
|
||||||
this.help(sender, false);
|
name = args.get(1);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final String name = args.get(1);
|
// bending preset list.
|
||||||
if (Arrays.asList(deletealiases).contains(args.get(0)) && this.hasPermission(sender, "delete")) { // bending preset delete name.
|
if (Arrays.asList(listaliases).contains(args.get(0)) && this.hasPermission(sender, "list")) {
|
||||||
|
boolean firstMessage = true;
|
||||||
|
|
||||||
|
final List<Preset> presets = Preset.presets.get(player.getUniqueId());
|
||||||
|
final List<String> presetNames = new ArrayList<String>();
|
||||||
|
|
||||||
|
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)) {
|
if (!Preset.presetExists(player, name)) {
|
||||||
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.noPresetName);
|
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.noPresetName);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue