@@ -10,6 +10,7 @@ import com.mairwunnx.projectessentials.projectessentialshome.EntryPoint.Companio
1010import com.mairwunnx.projectessentials.projectessentialshome.models.HomeModel
1111import com.mairwunnx.projectessentials.projectessentialshome.storage.StorageBase
1212import com.mojang.brigadier.CommandDispatcher
13+ import com.mojang.brigadier.arguments.BoolArgumentType
1314import com.mojang.brigadier.arguments.StringArgumentType
1415import com.mojang.brigadier.builder.LiteralArgumentBuilder.literal
1516import com.mojang.brigadier.context.CommandContext
@@ -34,7 +35,15 @@ object SetHomeCommand {
3435 " home name" , StringArgumentType .string()
3536 ).executes {
3637 return @executes execute(it)
37- }
38+ }.then(
39+ Commands .argument(
40+ " override" , BoolArgumentType .bool()
41+ ).executes {
42+ return @executes execute(
43+ it, BoolArgumentType .getBool(it, " override" )
44+ )
45+ }
46+ )
3847 )
3948 )
4049 }
@@ -45,7 +54,10 @@ object SetHomeCommand {
4554 CommandsAliases .aliases[" sethome" ] = aliases.toMutableList()
4655 }
4756
48- private fun execute (c : CommandContext <CommandSource >): Int {
57+ private fun execute (
58+ c : CommandContext <CommandSource >,
59+ override : Boolean = false
60+ ): Int {
4961 if (c.isPlayerSender()) {
5062 val player = c.source.asPlayer()
5163 if (hasPermission(player, " ess.home.set" )) {
@@ -63,6 +75,16 @@ object SetHomeCommand {
6375 val yaw = player.rotationYaw
6476 val pitch = player.rotationPitch
6577 val homeModel = StorageBase .getData(playerUUID).homes
78+
79+ if (! override ) {
80+ homeModel.forEach {
81+ if (it.home == homeName) {
82+ sendMsg(" home" , c.source, " home.set.already_exist" , homeName)
83+ return 0
84+ }
85+ }
86+ }
87+
6688 homeModel.add(
6789 HomeModel .Home (
6890 homeName, clientWorld, worldId, xPos, yPos, zPos, yaw, pitch
0 commit comments