@@ -7,9 +7,8 @@ import com.mairwunnx.projectessentials.core.helpers.throwOnlyPlayerCan
77import com.mairwunnx.projectessentials.core.helpers.throwPermissionLevel
88import com.mairwunnx.projectessentials.home.EntryPoint
99import com.mairwunnx.projectessentials.home.EntryPoint.Companion.hasPermission
10- import com.mairwunnx.projectessentials.home.models.HomeModel
10+ import com.mairwunnx.projectessentials.home.api.HomeAPI
1111import com.mairwunnx.projectessentials.home.sendMessage
12- import com.mairwunnx.projectessentials.home.storage.StorageBase
1312import com.mojang.brigadier.CommandDispatcher
1413import com.mojang.brigadier.arguments.BoolArgumentType
1514import com.mojang.brigadier.arguments.StringArgumentType
@@ -62,51 +61,19 @@ object SetHomeCommand {
6261 if (c.isPlayerSender()) {
6362 val player = c.source.asPlayer()
6463 if (hasPermission(player, " ess.home.set" )) {
65- val playerUUID = player.uniqueID.toString()
6664 val homeName: String = try {
6765 StringArgumentType .getString(c, " home name" )
6866 } catch (_: IllegalArgumentException ) {
6967 " home"
7068 }
71- val clientWorld = c.source.world.worldInfo.worldName
72- val worldId = c.source.world.worldType.id
73- val xPos = player.posX.toInt()
74- val yPos = player.posY.toInt()
75- val zPos = player.posZ.toInt()
76- val yaw = player.rotationYaw
77- val pitch = player.rotationPitch
78- val homeModel = StorageBase .getData(playerUUID).homes
7969
80- if (! override ) {
81- homeModel.forEach {
82- if (it.home == homeName) {
83- sendMessage(c.source, " set.already_exist" , homeName)
84- return 0
85- }
86- }
87- } else {
88- homeModel.removeAll {
89- it.home == homeName
90- }
70+ val result = HomeAPI .create(player, homeName, override )
71+ if (! result) {
72+ sendMessage(c.source, " set.already_exist" , homeName)
73+ return 0
9174 }
9275
93- homeModel.add(
94- HomeModel .Home (
95- homeName, clientWorld, worldId, xPos, yPos, zPos, yaw, pitch
96- )
97- )
98- StorageBase .setData(playerUUID, HomeModel (homeModel))
9976 sendMessage(c.source, " set.success" , homeName)
100- logger.info(
101- " \n " +
102- " New home point for ${player.name.string} installed with data: \n " +
103- " - name: $homeName \n " +
104- " - world / world id: $clientWorld / $worldId \n " +
105- " - xpos: $xPos \n " +
106- " - ypos: $yPos \n " +
107- " - zpos: $zPos \n " +
108- " - pitch: $pitch "
109- )
11077 logger.info(" Executed command \" /sethome\" from ${player.name.string} " )
11178 } else {
11279 sendMsg(" home" , c.source, " home.set.restricted" )
0 commit comments