diff --git a/idofront-commands/src/main/kotlin/com/mineinabyss/idofront/commands/brigadier/IdoCommand.kt b/idofront-commands/src/main/kotlin/com/mineinabyss/idofront/commands/brigadier/IdoCommand.kt index 78829f9..689a81f 100644 --- a/idofront-commands/src/main/kotlin/com/mineinabyss/idofront/commands/brigadier/IdoCommand.kt +++ b/idofront-commands/src/main/kotlin/com/mineinabyss/idofront/commands/brigadier/IdoCommand.kt @@ -77,8 +77,10 @@ open class IdoCommand( requires { init(it) } } - fun requiresPermission(permission: String) = requires { - sender.hasPermission("$permission.*") || sender.hasPermission(permission) + /** The permission to use for this command. If null, use default of plugin.commandname. If it is blank, require no permission */ + var permission: String? = null + fun requiresPermission(permission: String) { + this.permission = permission } /** Specifies an end node for the command that runs something, only one executes block can run per command execution. */ diff --git a/idofront-commands/src/main/kotlin/com/mineinabyss/idofront/commands/brigadier/RootIdoCommands.kt b/idofront-commands/src/main/kotlin/com/mineinabyss/idofront/commands/brigadier/RootIdoCommands.kt index 2234706..0608251 100644 --- a/idofront-commands/src/main/kotlin/com/mineinabyss/idofront/commands/brigadier/RootIdoCommands.kt +++ b/idofront-commands/src/main/kotlin/com/mineinabyss/idofront/commands/brigadier/RootIdoCommands.kt @@ -37,7 +37,10 @@ class RootIdoCommands( internal fun buildEach() { rootCommands.forEach { command -> commands.register( - command.build(), + command.apply { + val permission = permission ?: "${plugin.name}.$name" + if (permission.isNotEmpty()) requires { sender.hasPermission("$permission.*") || sender.hasPermission(permission) } + }.build(), command.description, command.aliases )