mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 06:50:12 +01:00
Fix HelpCommand searching
Prevent index out of bounds exception when finding possible matches in the help topics. A general empty string is caught and directed to the defaultTopic by getHelpTopic(). #findPossibleMatches hence should not concern itself with possible empty strings anymore.
This commit is contained in:
parent
cb339661cc
commit
7507d0f1ef
2 changed files with 9 additions and 3 deletions
|
@ -143,6 +143,7 @@ public class HelpCommand extends BukkitCommand {
|
|||
searchString = searchString.substring(1);
|
||||
}
|
||||
|
||||
if (searchString.isEmpty()) return null; // Paper - prevent index out of bounds - nothing matches an empty search string, should have been special cased to defaultTopic earlier, just return null.
|
||||
for (HelpTopic topic : Bukkit.getServer().getHelpMap().getHelpTopics()) {
|
||||
String trimmedTopic = topic.getName().startsWith("/") ? topic.getName().substring(1) : topic.getName();
|
||||
|
||||
|
|
|
@ -49,10 +49,15 @@ public class IndexHelpTopic extends HelpTopic {
|
|||
if (sender instanceof ConsoleCommandSender) {
|
||||
return true;
|
||||
}
|
||||
if (permission == null) {
|
||||
return true;
|
||||
// Paper start - Fix HelpCommand searching - do not show index if no topic is visible to the sender
|
||||
if (permission != null && !sender.hasPermission(permission)) return false; // old spigot permission check
|
||||
|
||||
for (HelpTopic topic : allTopics) {
|
||||
if (topic.canSee(sender)) return true;
|
||||
}
|
||||
return sender.hasPermission(permission);
|
||||
|
||||
return false;
|
||||
// Paper end - Fix HelpCommand searching - do not show index if no topic is visible to the sender
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue