mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-24 11:38:40 +01:00
Fix search command page number
This commit is contained in:
parent
da23b6ea9a
commit
1efce41767
@ -28,6 +28,7 @@ import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.generic.SharedSubCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.Util;
|
||||
import me.lucko.luckperms.common.constants.Constants;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
@ -56,14 +57,7 @@ public class PermissionInfo extends SharedSubCommand {
|
||||
Message.LISTNODES.send(sender, holder.getFriendlyName());
|
||||
sender.sendMessage(Util.color(Util.permNodesToStringConsole(holder.getPermissions(false))));
|
||||
} else {
|
||||
int page = 1;
|
||||
if (args.size() > 0) {
|
||||
try {
|
||||
page = Integer.parseInt(args.get(0));
|
||||
} catch (NumberFormatException e) {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
int page = ArgumentUtils.handleIntOrElse(0, args, 1);
|
||||
|
||||
Map.Entry<FancyMessage, String> ent = Util.permNodesToMessage(holder.getPermissions(false), holder, label, page);
|
||||
if (ent.getValue() != null) {
|
||||
|
@ -48,8 +48,7 @@ public class InfoCommand extends SingleCommand {
|
||||
try {
|
||||
int i = Integer.parseInt(value);
|
||||
return "&a" + i;
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
} catch (NumberFormatException ignored) {}
|
||||
|
||||
return "&f" + value;
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import me.lucko.luckperms.common.commands.CommandException;
|
||||
import me.lucko.luckperms.common.commands.CommandResult;
|
||||
import me.lucko.luckperms.common.commands.SingleCommand;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.commands.utils.ArgumentUtils;
|
||||
import me.lucko.luckperms.common.commands.utils.Util;
|
||||
import me.lucko.luckperms.common.constants.Message;
|
||||
import me.lucko.luckperms.common.constants.Permission;
|
||||
@ -56,15 +57,7 @@ public class SearchCommand extends SingleCommand {
|
||||
@Override
|
||||
public CommandResult execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) throws CommandException {
|
||||
String query = args.get(0);
|
||||
|
||||
int page = 1;
|
||||
if (args.size() > 1) {
|
||||
try {
|
||||
page = Integer.parseInt(args.get(1));
|
||||
} catch (NumberFormatException e) {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
int page = ArgumentUtils.handleIntOrElse(1, args, 1);
|
||||
|
||||
Message.SEARCH_SEARCHING.send(sender, query);
|
||||
|
||||
|
@ -52,6 +52,18 @@ public class ArgumentUtils {
|
||||
return args.get(index).replace("{SPACE}", " ");
|
||||
}
|
||||
|
||||
public static int handleIntOrElse(int index, List<String> args, int other) {
|
||||
if (index < 0 || index >= args.size()) {
|
||||
return other;
|
||||
}
|
||||
|
||||
try {
|
||||
return Integer.parseInt(args.get(index));
|
||||
} catch (NumberFormatException e) {
|
||||
return other;
|
||||
}
|
||||
}
|
||||
|
||||
public static String handleNode(int index, List<String> args) throws ArgumentException {
|
||||
String node = args.get(index).replace("{SPACE}", " ");
|
||||
if (ArgumentChecker.checkNode(node)) {
|
||||
|
Loading…
Reference in New Issue
Block a user