1
1
package com.mairwunnx.projectessentialspermissions.commands
2
2
3
+ import com.mairwunnx.projectessentialscooldown.essentials.CommandsAliases
3
4
import com.mairwunnx.projectessentialscore.extensions.isPlayerSender
4
5
import com.mairwunnx.projectessentialscore.extensions.playerName
5
6
import com.mairwunnx.projectessentialscore.extensions.sendMsg
@@ -16,12 +17,13 @@ import net.minecraft.command.CommandSource
16
17
import net.minecraft.command.Commands
17
18
import org.apache.logging.log4j.LogManager
18
19
19
- @Suppress(" DuplicatedCode" ) // todo: DuplicatedCode warning.
20
+ @Suppress(" DuplicatedCode" )
20
21
internal object PermissionsCommand {
21
- private val aliases = arrayOf (" essentials" , " ess" )
22
+ private val aliases = listOf (" essentials" , " ess" )
22
23
private val logger = LogManager .getLogger()
23
24
24
25
internal fun register (dispatcher : CommandDispatcher <CommandSource >) {
26
+ assignAliases()
25
27
aliases.forEach { command ->
26
28
dispatcher.register(
27
29
literal<CommandSource >(command).then(
@@ -35,6 +37,17 @@ internal object PermissionsCommand {
35
37
}
36
38
}
37
39
40
+ private fun assignAliases () {
41
+ try {
42
+ Class .forName(
43
+ " com.mairwunnx.projectessentialscooldown.essentials.CommandsAliases"
44
+ )
45
+ CommandsAliases .aliases[" essentials" ] = mutableListOf (" ess" )
46
+ } catch (_: ClassNotFoundException ) {
47
+ // ignored
48
+ }
49
+ }
50
+
38
51
private fun buildAboutCommand (): LiteralArgumentBuilder <CommandSource > {
39
52
return Commands .literal(" permissions" ).executes {
40
53
return @executes aboutCommandExecute(it)
@@ -101,6 +114,7 @@ internal object PermissionsCommand {
101
114
}
102
115
else -> {
103
116
PermissionBase .loadData()
117
+ assignAliases()
104
118
when {
105
119
c.isPlayerSender() -> sendMsg(
106
120
" permissions" , c.source, " perm.reload.success"
0 commit comments