11package com.mairwunnx.projectessentials.projectessentialshome.commands
22
3+ import com.mairwunnx.projectessentials.cooldown.essentials.CommandsAliases
4+ import com.mairwunnx.projectessentials.core.extensions.isPlayerSender
5+ import com.mairwunnx.projectessentials.core.extensions.sendMsg
6+ import com.mairwunnx.projectessentials.core.helpers.ONLY_PLAYER_CAN
7+ import com.mairwunnx.projectessentials.core.helpers.PERMISSION_LEVEL
8+ import com.mairwunnx.projectessentials.projectessentialshome.EntryPoint
9+ import com.mairwunnx.projectessentials.projectessentialshome.EntryPoint.Companion.hasPermission
310import com.mairwunnx.projectessentials.projectessentialshome.models.HomeModel
411import com.mairwunnx.projectessentials.projectessentialshome.storage.StorageBase
5- import com.mairwunnx.projectessentialscooldown.essentials.CommandsAliases
6- import com.mairwunnx.projectessentialscore.extensions.isPlayerSender
7- import com.mairwunnx.projectessentialscore.extensions.sendMsg
8- import com.mairwunnx.projectessentialscore.helpers.ONLY_PLAYER_CAN
9- import com.mairwunnx.projectessentialscore.helpers.PERMISSION_LEVEL
10- import com.mairwunnx.projectessentialspermissions.permissions.PermissionsAPI
1112import com.mojang.brigadier.CommandDispatcher
1213import com.mojang.brigadier.arguments.StringArgumentType
1314import com.mojang.brigadier.builder.LiteralArgumentBuilder.literal
@@ -16,13 +17,14 @@ import net.minecraft.command.CommandSource
1617import net.minecraft.command.Commands
1718import org.apache.logging.log4j.LogManager
1819
19- @Suppress(" DuplicatedCode" )
2020object SetHomeCommand {
2121 private val aliases = arrayOf(" sethome" , " esethome" )
2222 private val logger = LogManager .getLogger()
2323
2424 fun register (dispatcher : CommandDispatcher <CommandSource >) {
25- logger.info(" - register \" /sethome\" command ..." )
25+ logger.info(" Register \" /sethome\" command" )
26+ applyCommandAliases()
27+
2628 aliases.forEach { command ->
2729 dispatcher.register(
2830 literal<CommandSource >(command).executes {
@@ -36,25 +38,17 @@ object SetHomeCommand {
3638 )
3739 )
3840 }
39- applyCommandAliases()
4041 }
4142
4243 private fun applyCommandAliases () {
43- try {
44- Class .forName(
45- " com.mairwunnx.projectessentialscooldown.essentials.CommandsAliases"
46- )
47- CommandsAliases .aliases[" sethome" ] = aliases.toMutableList()
48- logger.info(" - applying aliases: $aliases " )
49- } catch (_: ClassNotFoundException ) {
50- // ignored
51- }
44+ if (! EntryPoint .cooldownsInstalled) return
45+ CommandsAliases .aliases[" sethome" ] = aliases.toMutableList()
5246 }
5347
5448 private fun execute (c : CommandContext <CommandSource >): Int {
5549 if (c.isPlayerSender()) {
5650 val player = c.source.asPlayer()
57- if (PermissionsAPI . hasPermission(player.name.string , " ess.home.set" )) {
51+ if (hasPermission(player, " ess.home.set" )) {
5852 val playerUUID = player.uniqueID.toString()
5953 val homeName: String = try {
6054 StringArgumentType .getString(c, " home name" )
0 commit comments