From 299316a915ab174b6b1f4c28008a673ad65ee065 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Wed, 17 Apr 2013 10:34:48 +0200 Subject: [PATCH] Use FPerm for invite and deinvite as opposed to checking ranks. --- src/com/massivecraft/factions/FPerm.java | 3 ++- src/com/massivecraft/factions/Faction.java | 3 --- src/com/massivecraft/factions/cmd/CmdFactionsDeinvite.java | 4 +++- src/com/massivecraft/factions/cmd/CmdFactionsInvite.java | 5 ++--- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/com/massivecraft/factions/FPerm.java b/src/com/massivecraft/factions/FPerm.java index fc2490a6..fee375ca 100644 --- a/src/com/massivecraft/factions/FPerm.java +++ b/src/com/massivecraft/factions/FPerm.java @@ -6,6 +6,7 @@ import java.util.HashSet; import java.util.Set; import org.bukkit.Location; +import org.bukkit.command.CommandSender; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Player; @@ -137,7 +138,7 @@ public enum FPerm RelationParticipator rpSubject = null; - if (testSubject instanceof Player) + if (testSubject instanceof CommandSender) { rpSubject = FPlayerColl.get().get(testSubject); } diff --git a/src/com/massivecraft/factions/Faction.java b/src/com/massivecraft/factions/Faction.java index 8f42daa1..4a506559 100644 --- a/src/com/massivecraft/factions/Faction.java +++ b/src/com/massivecraft/factions/Faction.java @@ -102,7 +102,6 @@ public class Faction extends Entity implements EconomyParticipator // The flag overrides are the modifications to the default values private Map flagOverrides; - // FIELDS: Permission <-> Groups management private Map> permOverrides; // Contains the modifications to the default values @@ -582,8 +581,6 @@ public class Faction extends Entity implements EconomyParticipator return RelationUtil.getColorOfThatToMe(this, observer); } - - // TODO: Implement a has enough feature. // -------------------------------------------- // // POWER diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsDeinvite.java b/src/com/massivecraft/factions/cmd/CmdFactionsDeinvite.java index ab7e3350..1c4a61da 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsDeinvite.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsDeinvite.java @@ -1,5 +1,6 @@ package com.massivecraft.factions.cmd; +import com.massivecraft.factions.FPerm; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; @@ -18,12 +19,13 @@ public class CmdFactionsDeinvite extends FCommand this.addRequiredArg("player"); this.addRequirements(ReqHasPerm.get(Perm.DEINVITE.node)); - this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER)); } @Override public void perform() { + if ( ! FPerm.INVITE.has(sender, myFaction, true)) return; + FPlayer you = this.arg(0, ARFPlayer.getStartAny()); if (you == null) return; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsInvite.java b/src/com/massivecraft/factions/cmd/CmdFactionsInvite.java index da0ee0e7..52af9887 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsInvite.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsInvite.java @@ -5,9 +5,7 @@ import com.massivecraft.factions.FPerm; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; -import com.massivecraft.factions.Rel; import com.massivecraft.factions.cmd.arg.ARFPlayer; -import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; import com.massivecraft.mcore.cmd.req.ReqHasPerm; import com.massivecraft.mcore.cmd.req.ReqIsPlayer; @@ -21,12 +19,13 @@ public class CmdFactionsInvite extends FCommand this.addRequirements(ReqHasPerm.get(Perm.INVITE.node)); this.addRequirements(ReqIsPlayer.get()); - this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER)); } @Override public void perform() { + if ( ! FPerm.INVITE.has(sender, myFaction, true)) return; + FPlayer you = this.arg(0, ARFPlayer.getStartAny()); if (you == null) return;