@@ -4,17 +4,20 @@ import co.aikar.commands.BaseCommand
44import co.aikar.commands.annotation.CommandAlias
55import co.aikar.commands.annotation.CommandCompletion
66import co.aikar.commands.annotation.Description
7+ import co.aikar.commands.annotation.Optional
78import co.aikar.commands.annotation.Subcommand
89import me.devnatan.inventoryframework.ViewFrame
910import org.bukkit.command.CommandSender
1011import org.bukkit.entity.Player
1112import org.trackedout.citadel.Citadel
1213import org.trackedout.citadel.getApplicableRegions
14+ import org.trackedout.citadel.getCenterLocation
1315import org.trackedout.citadel.getCubby
1416import org.trackedout.citadel.getCubbyByName
1517import org.trackedout.citadel.getCubbyForPlayer
1618import org.trackedout.citadel.regions
1719import org.trackedout.citadel.sendGreenMessage
20+ import org.trackedout.citadel.sendMiniMessage
1821import org.trackedout.citadel.sendRedMessage
1922import org.trackedout.client.apis.EventsApi
2023import org.trackedout.client.apis.ScoreApi
@@ -67,6 +70,28 @@ class CubbyManagementCommand(
6770 }
6871 }
6972
73+ @Subcommand(" cubby tp" )
74+ @Description(" Teleport a cubby" )
75+ @CommandCompletion(" @dbPlayers" )
76+ fun teleportToCubby (source : CommandSender , @Optional targetPlayer : String? ) {
77+ val world = plugin.server.worlds.find { it.name == " world" } ? : throw IllegalArgumentException (" World not found" )
78+
79+ if (source is Player ) {
80+ val playerName = targetPlayer ? : source.name
81+ val playerCubby = source.world.getCubbyForPlayer(playerName)
82+ if (playerCubby != null ) {
83+ val target = if (targetPlayer == null || targetPlayer == source.name) " your" else " ${playerName} 's"
84+ source.sendMiniMessage(" <green>Teleporting you to $target cubby! Use <blue>/do unstuck</blue> if you get stuck</green>" )
85+
86+ source.teleport(playerCubby.getCenterLocation(world))
87+ } else {
88+ source.sendRedMessage(" $playerName does not have a cubby" )
89+ }
90+ } else {
91+ source.sendRedMessage(" Cannot teleport to your cubby as you are not a player" )
92+ }
93+ }
94+
7095 @Subcommand(" cubby locate" )
7196 @Description(" Locate a cubby owned by another player" )
7297 @CommandCompletion(" @dbPlayers" )
0 commit comments