@@ -18,18 +18,23 @@ class CommandListener(
18
18
fun onCommand (event : SendCommandEvent , @First commandSource : CommandSource ) {
19
19
val wholeCommand = event.wholeCommand
20
20
val matchedAliasedMap = configAccessor.get().alias.aliases.mapNotNull { (alias, aliasConfig) ->
21
- aliasConfig to (AliasParser .parse(alias, wholeCommand) ? : return @mapNotNull null )
21
+ (alias to aliasConfig) to (AliasParser .parse(alias, wholeCommand) ? : return @mapNotNull null )
22
22
}.toList()
23
23
24
24
if (matchedAliasedMap.isEmpty()) return // doesn't match any of our aliases
25
25
26
26
if (matchedAliasedMap.size > 1 ) {
27
- val matchedAliasesString = matchedAliasedMap.joinToString(separator = " , " , prefix = " [" , postfix = " ]" , transform = { " '$it '" })
28
- logger.error(" More than alias matched! command: '$wholeCommand '; matched aliases: $matchedAliasesString " )
27
+ val matchedAliasesString = matchedAliasedMap.joinToString(separator = " , " , prefix = " [" , postfix = " ]" , transform = { " '${it.first.first} '" })
28
+ logger.error(" More than one alias matched! command: '$wholeCommand '; matched aliases: $matchedAliasesString " )
29
29
throw IllegalArgumentException (" More than one alias matched, report to admin!" )
30
30
}
31
31
32
- val (aliasConfig, arguments) = matchedAliasedMap.single()
32
+ val (aliasEntry, arguments) = matchedAliasedMap.single()
33
+ val (_, aliasConfig) = aliasEntry
34
+ if (! commandSource.hasPermission(aliasConfig.permission)) {
35
+ throw RuntimeException (" You don't have the permission to execute this command!" )
36
+ }
37
+
33
38
aliasConfig.commands.forEach {
34
39
var modifiedWholeCommand = it
35
40
arguments.forEach { (parameter, argument) -> modifiedWholeCommand = modifiedWholeCommand.replace(parameter, argument) }
0 commit comments