Skip to content

Commit 256c98b

Browse files
committed
Add 'do cubby tp' and 'do unstuck' commands
They do what you'd expect: - /do cubby tp <player> - teleports you to a player's cubby - /do unstuck - teleports you to the leaderboard area
1 parent 8479cfd commit 256c98b

4 files changed

Lines changed: 59 additions & 0 deletions

File tree

src/main/kotlin/org/trackedout/citadel/Citadel.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import org.trackedout.citadel.commands.ShutdownDungeonsCommand
2828
import org.trackedout.citadel.commands.SpectateCommand
2929
import org.trackedout.citadel.commands.StatusCommand
3030
import org.trackedout.citadel.commands.TestQueueCommand
31+
import org.trackedout.citadel.commands.UnstuckCommand
3132
import org.trackedout.citadel.commands.editableConfigs
3233
import org.trackedout.citadel.commands.toggleableConfigs
3334
import org.trackedout.citadel.config.cardConfig
@@ -194,6 +195,7 @@ class Citadel : JavaPlugin() {
194195
manager.registerCommand(ShowArtifakesCommand(this, eventsApi, scoreApi, viewFrame))
195196
manager.registerCommand(CubbyManagementCommand(this, eventsApi, scoreApi, viewFrame))
196197
manager.registerCommand(LeaderboardCommand(this))
198+
manager.registerCommand(UnstuckCommand(this))
197199

198200
val echoShardListener = EchoShardListener(this, inventoryApi, eventsApi, scoreApi, viewFrame, inventoryManager)
199201
server.pluginManager.registerEvents(echoShardListener, this)

src/main/kotlin/org/trackedout/citadel/WorldGuardExtensions.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ fun World.getCubbyForPlayer(playerName: String): ProtectedRegion? {
2626
}
2727
}
2828

29+
fun ProtectedRegion.getCenterLocation(world: World): Location {
30+
val min = this.minimumPoint.toVector3()
31+
val max = this.maximumPoint.toVector3()
32+
33+
val center = min.add(max.add(1.0, 1.0, 1.0)).multiply(0.5)
34+
35+
return Location(world, center.x, center.y, center.z)
36+
}
37+
2938
fun World.getApplicableRegions(location: Location): ApplicableRegionSet? {
3039
val playerLocation = BlockVector3.at(location.x, location.y, location.z)
3140
return this.regionManager()?.getApplicableRegions(playerLocation)

src/main/kotlin/org/trackedout/citadel/commands/CubbyManagementCommand.kt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,20 @@ import co.aikar.commands.BaseCommand
44
import co.aikar.commands.annotation.CommandAlias
55
import co.aikar.commands.annotation.CommandCompletion
66
import co.aikar.commands.annotation.Description
7+
import co.aikar.commands.annotation.Optional
78
import co.aikar.commands.annotation.Subcommand
89
import me.devnatan.inventoryframework.ViewFrame
910
import org.bukkit.command.CommandSender
1011
import org.bukkit.entity.Player
1112
import org.trackedout.citadel.Citadel
1213
import org.trackedout.citadel.getApplicableRegions
14+
import org.trackedout.citadel.getCenterLocation
1315
import org.trackedout.citadel.getCubby
1416
import org.trackedout.citadel.getCubbyByName
1517
import org.trackedout.citadel.getCubbyForPlayer
1618
import org.trackedout.citadel.regions
1719
import org.trackedout.citadel.sendGreenMessage
20+
import org.trackedout.citadel.sendMiniMessage
1821
import org.trackedout.citadel.sendRedMessage
1922
import org.trackedout.client.apis.EventsApi
2023
import 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")
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package org.trackedout.citadel.commands
2+
3+
import co.aikar.commands.BaseCommand
4+
import co.aikar.commands.annotation.CommandAlias
5+
import co.aikar.commands.annotation.Description
6+
import co.aikar.commands.annotation.Subcommand
7+
import org.bukkit.Location
8+
import org.bukkit.entity.Player
9+
import org.trackedout.citadel.Citadel
10+
import org.trackedout.citadel.sendGreenMessage
11+
12+
@CommandAlias("decked-out|do")
13+
class UnstuckCommand(
14+
private val plugin: Citadel,
15+
) : BaseCommand() {
16+
17+
@Subcommand("unstuck")
18+
@Description("Unstuck yourself")
19+
fun unstuck(player: Player) {
20+
player.sendGreenMessage("Be freeeee!")
21+
player.teleport(Location(player.world, -512.0, 114.0, 1980.0, 90f, 0f))
22+
}
23+
}

0 commit comments

Comments
 (0)