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

@ -439,6 +439,13 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
public void setPermission(String permission) { public void setPermission(String permission) {
this.permission = permissionPrefix + permission; 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 * 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 // Set the usage to what the parent's command is
setParameters(parent.getParameters()); setParameters(parent.getParameters());
setDescription(parent.getDescription()); setDescription(parent.getDescription());
setPermission(parent.getPermission()); inheritPermission();
} }
@Override @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 // Inherit parameters from the respective parent class - in this case, only /island go and /island sethome
setParameters(parent.getParameters()); setParameters(parent.getParameters());
setDescription(parent.getDescription()); setDescription(parent.getDescription());
setPermission(parent.getPermission()); inheritPermission();
} }
@Override @Override

View File

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