mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-15 14:13:56 +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);
|
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()) {
|
for (HelpTopic topic : Bukkit.getServer().getHelpMap().getHelpTopics()) {
|
||||||
String trimmedTopic = topic.getName().startsWith("/") ? topic.getName().substring(1) : topic.getName();
|
String trimmedTopic = topic.getName().startsWith("/") ? topic.getName().substring(1) : topic.getName();
|
||||||
|
|
||||||
|
|
|
@ -49,10 +49,15 @@ public class IndexHelpTopic extends HelpTopic {
|
||||||
if (sender instanceof ConsoleCommandSender) {
|
if (sender instanceof ConsoleCommandSender) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (permission == null) {
|
// Paper start - Fix HelpCommand searching - do not show index if no topic is visible to the sender
|
||||||
return true;
|
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
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue