diff options
author | Dico <dico.karssiens@gmail.com> | 2018-09-27 04:41:58 +0100 |
---|---|---|
committer | Dico <dico.karssiens@gmail.com> | 2018-09-27 04:41:58 +0100 |
commit | 307b7aee4af34e47139259db7049a85c682b7be2 (patch) | |
tree | 398ff3360f90e49cdc2a10d7872f6c6f787472bb /src/main/kotlin/io/dico/parcels2/command/ParcelOptionsInteractCommand.kt | |
parent | cdaba0ebd5b48d1f2d4579c873d83fdf6ea1a074 (diff) |
Tweaks
Diffstat (limited to 'src/main/kotlin/io/dico/parcels2/command/ParcelOptionsInteractCommand.kt')
-rw-r--r-- | src/main/kotlin/io/dico/parcels2/command/ParcelOptionsInteractCommand.kt | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/main/kotlin/io/dico/parcels2/command/ParcelOptionsInteractCommand.kt b/src/main/kotlin/io/dico/parcels2/command/ParcelOptionsInteractCommand.kt index 5c38b06..1b61660 100644 --- a/src/main/kotlin/io/dico/parcels2/command/ParcelOptionsInteractCommand.kt +++ b/src/main/kotlin/io/dico/parcels2/command/ParcelOptionsInteractCommand.kt @@ -4,11 +4,12 @@ import io.dico.dicore.command.* import io.dico.dicore.command.parameter.type.ParameterTypes import io.dico.parcels2.Interactables import io.dico.parcels2.ParcelProvider +import io.dico.parcels2.ParcelsPlugin import io.dico.parcels2.Privilege import org.bukkit.command.CommandSender import org.bukkit.entity.Player -class ParcelOptionsInteractCommand(val parcelProvider: ParcelProvider) : Command() { +class ParcelOptionsInteractCommand(val plugin: ParcelsPlugin) : Command() { init { setShortDescription("View and/or change the setting") @@ -20,10 +21,12 @@ class ParcelOptionsInteractCommand(val parcelProvider: ParcelProvider) : Command } override fun execute(sender: CommandSender, context: ExecutionContext): String? { + if (!plugin.storage.isConnected) err("Parcels cannot have their options changed right now because of a database error") + val interactableClass = Interactables[context.address.mainKey] val allowed: Boolean? = context.get("allowed") - val parcel = parcelProvider.getParcelRequired(sender as Player, + val parcel = plugin.parcelProvider.getParcelRequired(sender as Player, if (allowed == null) Privilege.DEFAULT else Privilege.CAN_MANAGE) if (allowed == null) { @@ -52,5 +55,3 @@ class ParcelOptionsInteractCommand(val parcelProvider: ParcelProvider) : Command } } - -private fun err(message: String): Nothing = throw CommandException(message)
\ No newline at end of file |