summaryrefslogtreecommitdiff
path: root/src/main/kotlin/io/dico/parcels2/command/CommandsGeneral.kt
diff options
context:
space:
mode:
authorDico Karssiens <dico.karssiens@gmail.com>2018-08-02 01:16:38 +0100
committerDico Karssiens <dico.karssiens@gmail.com>2018-08-02 01:16:38 +0100
commit3917855a72c60d1c78632949b4fea21471873347 (patch)
tree4dcdbd770b1a74cc307adc0c5a020617d4233351 /src/main/kotlin/io/dico/parcels2/command/CommandsGeneral.kt
parent472e700e0422d1829aa26e04b74e2077807e75f0 (diff)
Improve (ParcelTarget)ing for commands, ParcelOwner things, various little bits
Diffstat (limited to 'src/main/kotlin/io/dico/parcels2/command/CommandsGeneral.kt')
-rw-r--r--src/main/kotlin/io/dico/parcels2/command/CommandsGeneral.kt16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/main/kotlin/io/dico/parcels2/command/CommandsGeneral.kt b/src/main/kotlin/io/dico/parcels2/command/CommandsGeneral.kt
index fa9a696..929b0c7 100644
--- a/src/main/kotlin/io/dico/parcels2/command/CommandsGeneral.kt
+++ b/src/main/kotlin/io/dico/parcels2/command/CommandsGeneral.kt
@@ -9,7 +9,6 @@ import io.dico.dicore.command.annotation.RequireParameters
import io.dico.parcels2.ParcelOwner
import io.dico.parcels2.ParcelsPlugin
import io.dico.parcels2.blockvisitor.RegionTraversal
-import io.dico.parcels2.command.NamedParcelDefaultValue.FIRST_OWNED
import io.dico.parcels2.storage.getParcelBySerializedValue
import io.dico.parcels2.util.hasAdminManage
import io.dico.parcels2.util.hasParcelHomeOthers
@@ -49,18 +48,17 @@ class CommandsGeneral(plugin: ParcelsPlugin) : AbstractParcelCommands(plugin) {
"more than one parcel",
shortVersion = "teleports you to parcels")
@RequireParameters(0)
- suspend fun cmdHome(player: Player,
- @NamedParcelDefault(FIRST_OWNED) target: NamedParcelTarget): Any? {
- if (player !== target.player && !player.hasParcelHomeOthers) {
+ suspend fun cmdHome(player: Player, @ParcelTarget.Kind(ParcelTarget.OWNER_REAL) target: ParcelTarget): Any? {
+ val ownerTarget = target as ParcelTarget.ByOwner
+ if (!ownerTarget.owner.matches(player) && !player.hasParcelHomeOthers) {
error("You do not have permission to teleport to other people's parcels")
}
- val ownedParcelsResult = plugin.storage.getOwnedParcels(ParcelOwner(uuid = target.player.uuid)).await()
+ val ownedParcelsResult = plugin.storage.getOwnedParcels(ownerTarget.owner).await()
- val uuid = target.player.uuid
val ownedParcels = ownedParcelsResult
.map { worlds.getParcelBySerializedValue(it) }
- .filter { it != null && it.world == target.world && it.owner?.uuid == uuid }
+ .filter { it != null && ownerTarget.world == it.world && ownerTarget.owner == it.owner }
val targetMatch = ownedParcels.getOrNull(target.index)
?: error("The specified parcel could not be matched")
@@ -79,7 +77,7 @@ class CommandsGeneral(plugin: ParcelsPlugin) : AbstractParcelCommands(plugin) {
}
checkParcelLimit(player)
- parcel.owner = ParcelOwner(uuid = player.uuid, name = player.name)
+ parcel.owner = ParcelOwner(player)
return "Enjoy your new parcel!"
}
@@ -100,7 +98,7 @@ class CommandsGeneral(plugin: ParcelsPlugin) : AbstractParcelCommands(plugin) {
@Cmd("swap")
fun ParcelScope.cmdSwap(context: ExecutionContext, @Flag sure: Boolean): Any? {
-
+ TODO()
}
@Cmd("make_mess")