mirror of
https://github.com/aikar/commands.git
synced 2026-05-31 06:11:55 +00:00
Fix help page count
This commit is contained in:
@@ -32,6 +32,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public class CommandHelp {
|
||||
@@ -58,7 +59,7 @@ public class CommandHelp {
|
||||
|
||||
SetMultimap<String, RegisteredCommand> subCommands = rootCommand.getSubCommands();
|
||||
Set<RegisteredCommand> seen = new HashSet<>();
|
||||
|
||||
|
||||
if (!rootCommand.getDefCommand().hasHelpCommand) {
|
||||
RegisteredCommand defCommand = rootCommand.getDefaultRegisteredCommand();
|
||||
if (defCommand != null) {
|
||||
@@ -66,7 +67,7 @@ public class CommandHelp {
|
||||
seen.add(defCommand);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
subCommands.entries().forEach(e -> {
|
||||
String key = e.getKey();
|
||||
if (key.equals(BaseCommand.DEFAULT) || key.equals(BaseCommand.CATCHUNKNOWN)) {
|
||||
@@ -148,9 +149,8 @@ public class CommandHelp {
|
||||
return;
|
||||
}
|
||||
|
||||
List<HelpEntry> helpEntries = getHelpEntries();
|
||||
List<HelpEntry> helpEntries = getHelpEntries().stream().filter(HelpEntry::shouldShow).collect(Collectors.toList());
|
||||
Iterator<HelpEntry> results = helpEntries.stream()
|
||||
.filter(HelpEntry::shouldShow)
|
||||
.sorted(Comparator.comparingInt(helpEntry -> helpEntry.getSearchScore() * -1)).iterator();
|
||||
if (!results.hasNext()) {
|
||||
issuer.sendMessage(MessageType.ERROR, MessageKeys.NO_COMMAND_MATCHED_SEARCH, "{search}", ACFUtil.join(this.search, " "));
|
||||
@@ -246,6 +246,10 @@ public class CommandHelp {
|
||||
return totalPages;
|
||||
}
|
||||
|
||||
public boolean isOnlyPage() {
|
||||
return this.page == 1 && lastPage;
|
||||
}
|
||||
|
||||
public boolean isLastPage() {
|
||||
return lastPage;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public class CommandHelpFormatter {
|
||||
}
|
||||
|
||||
public void printHelpFooter(CommandHelp help, CommandIssuer issuer) {
|
||||
if (help.isLastPage()) {
|
||||
if (help.isOnlyPage()) {
|
||||
return;
|
||||
}
|
||||
issuer.sendMessage(MessageType.HELP, MessageKeys.HELP_PAGE_INFORMATION, getHeaderFooterFormatReplacements(help));
|
||||
@@ -107,7 +107,7 @@ public class CommandHelpFormatter {
|
||||
}
|
||||
|
||||
public void printSearchFooter(CommandHelp help, CommandIssuer issuer) {
|
||||
if (help.isLastPage()) {
|
||||
if (help.isOnlyPage()) {
|
||||
return;
|
||||
}
|
||||
issuer.sendMessage(MessageType.HELP, MessageKeys.HELP_PAGE_INFORMATION, getHeaderFooterFormatReplacements(help));
|
||||
|
||||
Reference in New Issue
Block a user