Fixes help permissions.

This commit is contained in:
tastybento 2018-06-02 08:39:45 -07:00
parent d94477034a
commit 320c9a9f43
4 changed files with 10 additions and 2 deletions

View File

@ -440,6 +440,13 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
this.permission = permissionPrefix + permission;
}
/**
* Inherits the permission from parent command
*/
public void inheritPermission() {
this.permission = parent.getPermission();
}
/**
* This creates the full linking chain of commands
*/

View File

@ -32,7 +32,7 @@ public class DefaultHelpCommand extends CompositeCommand {
// Set the usage to what the parent's command is
setParameters(parent.getParameters());
setDescription(parent.getDescription());
setPermission(parent.getPermission());
inheritPermission();
}
@Override

View File

@ -26,7 +26,7 @@ public class CustomIslandMultiHomeHelp extends CompositeCommand {
// Inherit parameters from the respective parent class - in this case, only /island go and /island sethome
setParameters(parent.getParameters());
setDescription(parent.getDescription());
setPermission(parent.getPermission());
inheritPermission();
}
@Override

View File

@ -127,6 +127,7 @@ public class DefaultHelpCommandTest {
CompositeCommand cc = mock(CompositeCommand.class);
DefaultHelpCommand dhc = new DefaultHelpCommand(cc);
assertNotNull(dhc);
// Verify that parent's parameters and permission is used
Mockito.verify(cc).getParameters();
Mockito.verify(cc).getDescription();
Mockito.verify(cc).getPermission();