Add rank check to /f ban (#1068)

* Add rank check to /f ban

* Fix incorrect f perm check at SetHome
This commit is contained in:
Dariasc 2018-03-04 00:12:14 -03:00 committed by Trent Hensler
parent fa007e5674
commit a8ce60b457
3 changed files with 16 additions and 3 deletions

View File

@ -6,6 +6,7 @@ import com.massivecraft.factions.event.FPlayerLeaveEvent;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.zcore.fperms.Access;
import com.massivecraft.factions.zcore.fperms.Permissable;
import com.massivecraft.factions.zcore.fperms.PermissableAction;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit;
@ -37,10 +38,10 @@ public class CmdBan extends FCommand {
return;
}
// Can the player set the home for this faction?
// Can the player ban for this faction?
// Check for ALLOW access as well before we check for role.
if (access != Access.ALLOW) {
if (!Permission.BAN.has(sender) && !(assertMinRole(Role.MODERATOR))) {
if (!Permission.BAN.has(sender, true) || !assertMinRole(Role.MODERATOR)) {
return;
}
} else {
@ -55,6 +56,16 @@ public class CmdBan extends FCommand {
return; // the above method sends a message if fails to find someone.
}
if (fme == target) {
// You may not ban yourself
fme.msg(TL.COMMAND_BAN_SELF);
return;
} else if (target.getFaction() == myFaction && target.getRole().value >= fme.getRole().value) {
// You may not ban someone that has same or higher faction rank
fme.msg(TL.COMMAND_BAN_INSUFFICIENTRANK, target.getName());
return;
}
// Ban the user.
myFaction.ban(target, fme);
myFaction.deinvite(target); // can't hurt

View File

@ -48,7 +48,7 @@ public class CmdSethome extends FCommand {
// Can the player set the home for this faction?
// Check for ALLOW access as well before we check for role.
if (faction == myFaction && access != Access.ALLOW) {
if (!Permission.SETHOME_ANY.has(sender) && !(assertMinRole(Role.MODERATOR))) {
if (!Permission.SETHOME_ANY.has(sender) || !assertMinRole(Role.MODERATOR)) {
return;
}
} else {

View File

@ -78,6 +78,8 @@ public enum TL {
COMMAND_BAN_DESCRIPTION("Ban players from joining your Faction."),
COMMAND_BAN_TARGET("&cYou were banned from &7%1$s"), // banned player perspective
COMMAND_BAN_BANNED("&e%1$s &cbanned &7%2$s"),
COMMAND_BAN_SELF("&cYou may not ban yourself"),
COMMAND_BAN_INSUFFICIENTRANK("&cYour rank is too low to ban &7%1$s"),
COMMAND_BANLIST_DESCRIPTION("View a Faction's ban list"),
COMMAND_BANLIST_HEADER("&6There are &c%d&6 bans for %s"),