F perm for invite and sethome

This commit is contained in:
Trent Hensler 2018-02-03 12:56:16 -08:00
parent 3eda8750cc
commit baea59a1cd
2 changed files with 21 additions and 3 deletions

View File

@ -3,6 +3,9 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer;
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.PermissableAction;
import com.massivecraft.factions.zcore.util.TL;
import mkremins.fanciful.FancyMessage;
import org.bukkit.ChatColor;
@ -22,7 +25,7 @@ public class CmdInvite extends FCommand {
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = true;
senderMustBeModerator = false;
senderMustBeAdmin = false;
}
@ -44,6 +47,12 @@ public class CmdInvite extends FCommand {
return;
}
Access access = myFaction.getAccess(you, PermissableAction.INVITE);
if (access == Access.DENY || (access == Access.UNDEFINED && !assertMinRole(Role.MODERATOR))) {
fme.msg(TL.GENERIC_NOPERMISSION, "invite");
return;
}
myFaction.invite(you);
if (!you.isOnline()) {
return;

View File

@ -6,6 +6,8 @@ import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction;
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.PermissableAction;
import com.massivecraft.factions.zcore.util.TL;
public class CmdSethome extends FCommand {
@ -37,9 +39,16 @@ public class CmdSethome extends FCommand {
return;
}
Access access = faction.getAccess(fme, PermissableAction.SETHOME);
if (access == Access.DENY) {
fme.msg(TL.GENERIC_NOPERMISSION, "sethome");
return;
}
// Can the player set the home for this faction?
if (faction == myFaction) {
if (!Permission.SETHOME_ANY.has(sender) && !assertMinRole(Role.MODERATOR)) {
// Check for ALLOW access as well before we check for role.
if (faction == myFaction && access != Access.ALLOW) {
if (!Permission.SETHOME_ANY.has(sender) && !(Role.MODERATOR.value > fme.getRole().value)) {
return;
}
} else {