Better Help Command Visibility

This commit is contained in:
Olof Larsson 2016-03-17 20:26:55 +01:00
parent 3f262e13bc
commit 8b88dbe15b

View File

@ -68,12 +68,15 @@ public class MassiveCommandHelp extends MassiveCommand
boolean visible = super.isVisibleTo(sender); boolean visible = super.isVisibleTo(sender);
if ( ! (this.hasParent() && visible)) return visible; if ( ! (this.hasParent() && visible)) return visible;
int visibleSiblingCount = 0;
for (MassiveCommand sibling : this.getParent().getChildren())
{
if (sibling == this) continue;
if (sibling.isVisibleTo(sender)) visibleSiblingCount++;
}
int pageHeight = (sender instanceof Player) ? Txt.PAGEHEIGHT_PLAYER : Txt.PAGEHEIGHT_CONSOLE; int pageHeight = (sender instanceof Player) ? Txt.PAGEHEIGHT_PLAYER : Txt.PAGEHEIGHT_CONSOLE;
if (visibleSiblingCount <= pageHeight)
// Minues one, don't count ourself.
int size = this.getParent().getChildren().size()-1;
if (size <= pageHeight)
{ {
return false; return false;
} }