Skip to content

Commit fd86133

Browse files
committed
Compiler errors fixed for HomeCommand.kt.
Signed-off-by: Pavel Erokhin (MairwunNx) <[email protected]>
1 parent eabcb77 commit fd86133

File tree

1 file changed

+14
-19
lines changed
  • src/main/kotlin/com/mairwunnx/projectessentials/projectessentialshome/commands

1 file changed

+14
-19
lines changed

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

Lines changed: 14 additions & 19 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
@@ -24,7 +25,9 @@ object HomeCommand {
2425
private val logger = LogManager.getLogger()
2526

2627
fun register(dispatcher: CommandDispatcher<CommandSource>) {
27-
logger.info(" - register \"/home\" command ...")
28+
logger.info("Register \"/home\" command ...")
29+
applyCommandAliases()
30+
2831
aliases.forEach { command ->
2932
dispatcher.register(
3033
literal<CommandSource>(command).executes {
@@ -38,25 +41,17 @@ object HomeCommand {
3841
)
3942
)
4043
}
41-
applyCommandAliases()
4244
}
4345

4446
private fun applyCommandAliases() {
45-
try {
46-
Class.forName(
47-
"com.mairwunnx.projectessentialscooldown.essentials.CommandsAliases"
48-
)
49-
CommandsAliases.aliases["home"] = aliases.toMutableList()
50-
logger.info(" - applying aliases: $aliases")
51-
} catch (_: ClassNotFoundException) {
52-
// ignored
53-
}
47+
if (!EntryPoint.cooldownsInstalled) return
48+
CommandsAliases.aliases["home"] = aliases.toMutableList()
5449
}
5550

5651
private fun execute(c: CommandContext<CommandSource>): Int {
5752
if (c.isPlayerSender()) {
5853
val player = c.source.asPlayer()
59-
if (PermissionsAPI.hasPermission(player.name.string, "ess.home")) {
54+
if (hasPermission(player, "ess.home")) {
6055
val playerUUID = player.uniqueID.toString()
6156
val homeName: String = try {
6257
StringArgumentType.getString(c, "home name")
@@ -86,7 +81,7 @@ object HomeCommand {
8681
return 0
8782
}
8883

89-
fun moveToHome(player: ServerPlayerEntity, home: HomeModel.Home) {
84+
private fun moveToHome(player: ServerPlayerEntity, home: HomeModel.Home) {
9085
val xPos = home.xPos.toDouble()
9186
val yPos = home.yPos.toDouble()
9287
val zPos = home.zPos.toDouble()

0 commit comments

Comments
 (0)