Fix title edit permission check.

This commit is contained in:
Olof Larsson 2015-08-26 08:23:08 +02:00
parent 33964d4aa2
commit 6853923264
2 changed files with 6 additions and 44 deletions

View File

@ -51,8 +51,12 @@ public class CmdFactionsTitle extends FactionsCommand
// MPerm // MPerm
if ( ! MPerm.getPermTitle().has(msender, you.getFaction(), true)) return; if ( ! MPerm.getPermTitle().has(msender, you.getFaction(), true)) return;
// Verify // Rank Check
if ( ! canIAdministerYou(msender, you)) return; if (you.getRole().isMoreThan(msender.getRole()))
{
msg("<b>You can not edit titles for higher ranks.");
return;
}
// Event // Event
EventFactionsTitleChange event = new EventFactionsTitleChange(sender, you, newTitle); EventFactionsTitleChange event = new EventFactionsTitleChange(sender, you, newTitle);

View File

@ -1,10 +1,8 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.cmd.MassiveCommand;
import com.massivecraft.massivecore.util.Txt;
public class FactionsCommand extends MassiveCommand public class FactionsCommand extends MassiveCommand
{ {
@ -34,44 +32,4 @@ public class FactionsCommand extends MassiveCommand
this.msenderFaction = null; this.msenderFaction = null;
} }
// -------------------------------------------- //
// COMMONLY USED LOGIC
// -------------------------------------------- //
public boolean canIAdministerYou(MPlayer i, MPlayer you)
{
if ( ! i.getFaction().equals(you.getFaction()))
{
i.sendMessage(Txt.parse("%s <b>is not in the same faction as you.",you.describeTo(i, true)));
return false;
}
if (i.getRole().isMoreThan(you.getRole()) || i.getRole().equals(Rel.LEADER) )
{
return true;
}
if (you.getRole().equals(Rel.LEADER))
{
i.sendMessage(Txt.parse("<b>Only the faction leader can do that."));
}
else if (i.getRole().equals(Rel.OFFICER))
{
if ( i == you )
{
return true; //Moderators can control themselves
}
else
{
i.sendMessage(Txt.parse("<b>Officers can't control each other..."));
}
}
else
{
i.sendMessage(Txt.parse("<b>You must be a faction officer to do that."));
}
return false;
}
} }