From 03a70078d8290dce1f84b7124930a3d09fef9e78 Mon Sep 17 00:00:00 2001 From: Dico Date: Mon, 24 Sep 2018 02:56:09 +0100 Subject: Prevent mod changing perms of mod on parcels --- src/main/kotlin/io/dico/parcels2/command/CommandsPrivilegesLocal.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/kotlin/io/dico/parcels2/command/CommandsPrivilegesLocal.kt b/src/main/kotlin/io/dico/parcels2/command/CommandsPrivilegesLocal.kt index 16b99af..ba0536b 100644 --- a/src/main/kotlin/io/dico/parcels2/command/CommandsPrivilegesLocal.kt +++ b/src/main/kotlin/io/dico/parcels2/command/CommandsPrivilegesLocal.kt @@ -45,6 +45,7 @@ class CommandsPrivilegesLocal(plugin: ParcelsPlugin) : AbstractParcelCommands(pl fun ParcelScope.cmdAllow(sender: Player, player: OfflinePlayer): Any? { Validate.isTrue(parcel.owner != null || sender.hasPermAdminManage, "This parcel is unowned") Validate.isTrue(!parcel.owner!!.matches(player), "The target already owns the parcel") + Validate.isTrue(parcel.privilege(sender) > parcel.privilege(player), "You may not change the privilege of ${player.name}") Validate.isTrue(parcel.allowBuild(player), "${player.name} is already allowed to build on this parcel") return "${player.name} is now allowed to build on this parcel" } @@ -57,6 +58,7 @@ class CommandsPrivilegesLocal(plugin: ParcelsPlugin) : AbstractParcelCommands(pl ) @RequireParcelPrivilege(Privilege.CAN_MANAGE) fun ParcelScope.cmdDisallow(sender: Player, player: OfflinePlayer): Any? { + Validate.isTrue(parcel.privilege(sender) > parcel.privilege(player), "You may not change the privilege of ${player.name}") Validate.isTrue(parcel.disallowBuild(player), "${player.name} is not currently allowed to build on this parcel") return "${player.name} is not allowed to build on this parcel anymore" } @@ -71,6 +73,7 @@ class CommandsPrivilegesLocal(plugin: ParcelsPlugin) : AbstractParcelCommands(pl fun ParcelScope.cmdBan(sender: Player, player: OfflinePlayer): Any? { Validate.isTrue(parcel.owner != null || sender.hasPermAdminManage, "This parcel is unowned") Validate.isTrue(!parcel.owner!!.matches(player), "The owner cannot be banned from the parcel") + Validate.isTrue(parcel.privilege(sender) > parcel.privilege(player), "You may not change the privilege of ${player.name}") Validate.isTrue(parcel.ban(player), "${player.name} is already banned from this parcel") return "${player.name} is now banned from this parcel" } @@ -83,6 +86,7 @@ class CommandsPrivilegesLocal(plugin: ParcelsPlugin) : AbstractParcelCommands(pl ) @RequireParcelPrivilege(Privilege.CAN_MANAGE) fun ParcelScope.cmdUnban(sender: Player, player: OfflinePlayer): Any? { + Validate.isTrue(parcel.privilege(sender) > parcel.privilege(player), "You may not change the privilege of ${player.name}") Validate.isTrue(parcel.unban(player), "${player.name} is not currently banned from this parcel") return "${player.name} is not banned from this parcel anymore" } -- cgit v1.2.3