Skip to content

Commit 86bd30e

Browse files
committed
Compiler errors fixed for DelHomeCommand.kt.
Signed-off-by: Pavel Erokhin (MairwunNx) <MairwunNx@gmail.com>
1 parent fd86133 commit 86bd30e

File tree

1 file changed

+11
-18
lines changed
  • src/main/kotlin/com/mairwunnx/projectessentials/projectessentialshome/commands

1 file changed

+11
-18
lines changed

src/main/kotlin/com/mairwunnx/projectessentials/projectessentialshome/commands/DelHomeCommand.kt

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package 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
310
import com.mairwunnx.projectessentials.projectessentialshome.models.HomeModel
411
import 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
1112
import com.mojang.brigadier.CommandDispatcher
1213
import com.mojang.brigadier.arguments.StringArgumentType
1314
import com.mojang.brigadier.builder.LiteralArgumentBuilder.literal
@@ -16,13 +17,12 @@ import net.minecraft.command.CommandSource
1617
import net.minecraft.command.Commands
1718
import org.apache.logging.log4j.LogManager
1819

19-
@Suppress("DuplicatedCode")
2020
object DelHomeCommand {
2121
private val aliases = arrayOf("delhome", "edelhome", "removehome", "remhome")
2222
private val logger = LogManager.getLogger()
2323

2424
fun register(dispatcher: CommandDispatcher<CommandSource>) {
25-
logger.info(" - register \"/delhome\" command ...")
25+
logger.info("Register \"/delhome\" command ...")
2626
aliases.forEach { command ->
2727
dispatcher.register(
2828
literal<CommandSource>(command).executes {
@@ -40,21 +40,14 @@ object DelHomeCommand {
4040
}
4141

4242
private fun applyCommandAliases() {
43-
try {
44-
Class.forName(
45-
"com.mairwunnx.projectessentialscooldown.essentials.CommandsAliases"
46-
)
47-
CommandsAliases.aliases["delhome"] = aliases.toMutableList()
48-
logger.info(" - applying aliases: $aliases")
49-
} catch (_: ClassNotFoundException) {
50-
// ignored
51-
}
43+
if (!EntryPoint.cooldownsInstalled) return
44+
CommandsAliases.aliases["delhome"] = aliases.toMutableList()
5245
}
5346

5447
private fun execute(c: CommandContext<CommandSource>): Int {
5548
if (c.isPlayerSender()) {
5649
val player = c.source.asPlayer()
57-
if (PermissionsAPI.hasPermission(player.name.string, "ess.home.remove")) {
50+
if (hasPermission(player, "ess.home.remove")) {
5851
val playerUUID = player.uniqueID.toString()
5952
val homeName: String = try {
6053
StringArgumentType.getString(c, "home name")

0 commit comments

Comments
 (0)