diff options
Diffstat (limited to 'src/main/kotlin/io/dico/parcels2/command/CommandsPrivilegesGlobal.kt')
-rw-r--r-- | src/main/kotlin/io/dico/parcels2/command/CommandsPrivilegesGlobal.kt | 65 |
1 files changed, 18 insertions, 47 deletions
diff --git a/src/main/kotlin/io/dico/parcels2/command/CommandsPrivilegesGlobal.kt b/src/main/kotlin/io/dico/parcels2/command/CommandsPrivilegesGlobal.kt index e225cb5..9e3ac23 100644 --- a/src/main/kotlin/io/dico/parcels2/command/CommandsPrivilegesGlobal.kt +++ b/src/main/kotlin/io/dico/parcels2/command/CommandsPrivilegesGlobal.kt @@ -1,29 +1,21 @@ -@file:Suppress("NON_EXHAUSTIVE_WHEN") - package io.dico.parcels2.command +import io.dico.dicore.command.ExecutionContext import io.dico.dicore.command.annotation.Cmd import io.dico.dicore.command.annotation.Desc import io.dico.parcels2.ParcelsPlugin -import io.dico.parcels2.PrivilegeChangeResult.* -import org.bukkit.OfflinePlayer +import io.dico.parcels2.PlayerProfile import org.bukkit.entity.Player -class CommandsPrivilegesGlobal(plugin: ParcelsPlugin) : AbstractParcelCommands(plugin) { - private val data - inline get() = plugin.globalPrivileges - +class CommandsPrivilegesGlobal(plugin: ParcelsPlugin, + val adminVersion: CommandsAdminPrivilegesGlobal) : AbstractParcelCommands(plugin) { @Cmd("entrust") @Desc( - "Allows a player to manage this parcel", - shortVersion = "allows a player to manage this parcel" + "Allows a player to manage globally", + shortVersion = "allows a player to manage globally" ) - fun cmdEntrust(sender: Player, player: OfflinePlayer): Any? = - when (data[sender].allowManage(player)) { - FAIL_OWNER -> err("The target cannot be yourself") - FAIL -> err("${player.name} is already allowed to manage globally") - SUCCESS -> "${player.name} is now allowed to manage globally" - } + suspend fun cmdEntrust(sender: Player, context: ExecutionContext, player: PlayerProfile) = + adminVersion.cmdEntrust(context, sender, player) @Cmd("distrust") @Desc( @@ -31,12 +23,8 @@ class CommandsPrivilegesGlobal(plugin: ParcelsPlugin) : AbstractParcelCommands(p "they will still be able to build", shortVersion = "disallows a player to manage globally" ) - fun cmdDistrust(sender: Player, player: OfflinePlayer): Any? = - when (data[sender].disallowManage(player)) { - FAIL_OWNER -> err("The target cannot be yourself") - FAIL -> err("${player.name} is not currently allowed to manage globally") - SUCCESS -> "${player.name} is not allowed to manage globally anymore" - } + suspend fun cmdDistrust(sender: Player, context: ExecutionContext, player: PlayerProfile) = + adminVersion.cmdDistrust(context, sender, player) @Cmd("allow", aliases = ["add", "permit"]) @Desc( @@ -44,12 +32,8 @@ class CommandsPrivilegesGlobal(plugin: ParcelsPlugin) : AbstractParcelCommands(p "the parcels that you own.", shortVersion = "globally allows a player to build on your parcels" ) - fun cmdAllow(sender: Player, player: OfflinePlayer): Any? = - when (data[sender].allowBuild(player)) { - FAIL_OWNER -> err("The target cannot be yourself") - FAIL -> err("${player.name} is already allowed globally") - SUCCESS -> "${player.name} is now allowed to build on all your parcels" - } + suspend fun cmdAllow(sender: Player, context: ExecutionContext, player: PlayerProfile) = + adminVersion.cmdAllow(context, sender, player) @Cmd("disallow", aliases = ["remove", "forbid"]) @Desc( @@ -59,12 +43,8 @@ class CommandsPrivilegesGlobal(plugin: ParcelsPlugin) : AbstractParcelCommands(p "parcels, they can still build there.", shortVersion = "globally disallows a player to build on your parcels" ) - fun cmdDisallow(sender: Player, player: OfflinePlayer): Any? = - when (data[sender].disallowBuild(player)) { - FAIL_OWNER -> err("The target cannot be yourself") - FAIL -> err("${player.name} is not currently allowed globally") - SUCCESS -> "${player.name} is not allowed to build on all your parcels anymore" - } + suspend fun cmdDisallow(sender: Player, context: ExecutionContext, player: PlayerProfile) = + adminVersion.cmdDisallow(context, sender, player) @Cmd("ban", aliases = ["deny"]) @Desc( @@ -72,12 +52,8 @@ class CommandsPrivilegesGlobal(plugin: ParcelsPlugin) : AbstractParcelCommands(p "that you own, making them unable to enter.", shortVersion = "globally bans a player from your parcels" ) - fun cmdBan(sender: Player, player: OfflinePlayer): Any? = - when (data[sender].ban(player)) { - FAIL_OWNER -> err("The target cannot be yourself") - FAIL -> err("${player.name} is already banned from all your parcels") - SUCCESS -> "${player.name} is now banned from all your parcels" - } + suspend fun cmdBan(sender: Player, context: ExecutionContext, player: PlayerProfile) = + adminVersion.cmdBan(context, sender, player) @Cmd("unban", aliases = ["undeny"]) @Desc( @@ -87,11 +63,6 @@ class CommandsPrivilegesGlobal(plugin: ParcelsPlugin) : AbstractParcelCommands(p "they will still be banned there.", shortVersion = "globally unbans a player from your parcels" ) - fun cmdUnban(sender: Player, player: OfflinePlayer): Any? = - when (data[sender].unban(player)) { - FAIL_OWNER -> err("The target cannot be yourself") - FAIL -> err("${player.name} is not currently banned from all your parcels") - SUCCESS -> "${player.name} is not banned from all your parcels anymore" - } - + suspend fun cmdUnban(sender: Player, context: ExecutionContext, player: PlayerProfile) = + adminVersion.cmdUnban(context, sender, player) }
\ No newline at end of file |