diff --git a/src/main/java/us/tastybento/bskyblock/api/commands/CompositeCommand.java b/src/main/java/us/tastybento/bskyblock/api/commands/CompositeCommand.java index d4eed5d43..7771c0781 100644 --- a/src/main/java/us/tastybento/bskyblock/api/commands/CompositeCommand.java +++ b/src/main/java/us/tastybento/bskyblock/api/commands/CompositeCommand.java @@ -439,6 +439,13 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi public void setPermission(String 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 diff --git a/src/main/java/us/tastybento/bskyblock/api/commands/DefaultHelpCommand.java b/src/main/java/us/tastybento/bskyblock/api/commands/DefaultHelpCommand.java index 9bc892b92..cd1a500ee 100644 --- a/src/main/java/us/tastybento/bskyblock/api/commands/DefaultHelpCommand.java +++ b/src/main/java/us/tastybento/bskyblock/api/commands/DefaultHelpCommand.java @@ -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 diff --git a/src/main/java/us/tastybento/bskyblock/commands/island/CustomIslandMultiHomeHelp.java b/src/main/java/us/tastybento/bskyblock/commands/island/CustomIslandMultiHomeHelp.java index b16f99e06..0eba0c831 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/island/CustomIslandMultiHomeHelp.java +++ b/src/main/java/us/tastybento/bskyblock/commands/island/CustomIslandMultiHomeHelp.java @@ -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 diff --git a/src/test/java/us/tastybento/bskyblock/api/commands/DefaultHelpCommandTest.java b/src/test/java/us/tastybento/bskyblock/api/commands/DefaultHelpCommandTest.java index 29171926b..ca71f247d 100644 --- a/src/test/java/us/tastybento/bskyblock/api/commands/DefaultHelpCommandTest.java +++ b/src/test/java/us/tastybento/bskyblock/api/commands/DefaultHelpCommandTest.java @@ -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();