mirror of
https://github.com/MassiveCraft/Factions.git
synced 2024-12-29 12:07:59 +01:00
Leaders can now not be kicked by their officers. Improved leader command.
This commit is contained in:
parent
3dc70e82d9
commit
81d24ecbc4
@ -102,7 +102,7 @@ permissions:
|
||||
factions.kick:
|
||||
description: kick a player from the faction
|
||||
factions.leader:
|
||||
description: hand over your leader rights
|
||||
description: hand over leader rights
|
||||
factions.leave:
|
||||
description: leave your faction
|
||||
factions.list:
|
||||
|
@ -40,6 +40,12 @@ public class CmdKick extends FCommand
|
||||
msg("<i>You might want to: %s", p.cmdBase.cmdLeave.getUseageTemplate(false));
|
||||
return;
|
||||
}
|
||||
|
||||
if (you.getRole() == Rel.LEADER && !(this.senderIsConsole || fme.hasAdminMode()))
|
||||
{
|
||||
msg("<b>The leader can not be kicked.");
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! Conf.canLeaveWithNegativePower && you.getPower() < 0)
|
||||
{
|
||||
|
@ -2,8 +2,10 @@ package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
import com.massivecraft.factions.util.RelationUtil;
|
||||
|
||||
public class CmdLeader extends FCommand
|
||||
{
|
||||
@ -13,43 +15,67 @@ public class CmdLeader extends FCommand
|
||||
this.aliases.add("leader");
|
||||
|
||||
this.requiredArgs.add("player");
|
||||
//this.optionalArgs.put("", "");
|
||||
this.optionalArgs.put("faction", "your");
|
||||
|
||||
this.permission = Permission.LEADER.node;
|
||||
this.disableOnLock = true;
|
||||
|
||||
senderMustBePlayer = true;
|
||||
senderMustBePlayer = false;
|
||||
senderMustBeMember = false;
|
||||
senderMustBeOfficer = false;
|
||||
senderMustBeLeader = true;
|
||||
senderMustBeLeader = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void perform()
|
||||
{
|
||||
FPlayer fyou = this.argAsBestFPlayerMatch(0);
|
||||
if (fyou == null) return;
|
||||
FPlayer newLeader = this.argAsBestFPlayerMatch(0);
|
||||
if (newLeader == null) return;
|
||||
|
||||
if (fyou.getFaction() != myFaction)
|
||||
Faction targetFaction = this.argAsFaction(1, myFaction);
|
||||
if (targetFaction == null) return;
|
||||
|
||||
FPlayer targetFactionCurrentLeader = targetFaction.getFPlayerLeader();
|
||||
|
||||
// We now have fplayer and the target faction
|
||||
if (this.senderIsConsole || fme.hasAdminMode())
|
||||
{
|
||||
msg("%s<i> is not a member in your faction.", fyou.describeTo(fme, true));
|
||||
return;
|
||||
// Do whatever you wish
|
||||
}
|
||||
else
|
||||
{
|
||||
// Follow the standard rules
|
||||
if (fme.getRole() != Rel.LEADER)
|
||||
{
|
||||
sender.sendMessage(p.txt.parse("<b>Only faction admins can %s.", this.getHelpShort()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (newLeader.getFaction() != myFaction)
|
||||
{
|
||||
msg("%s<i> is not a member in your faction.", newLeader.describeTo(fme, true));
|
||||
return;
|
||||
}
|
||||
|
||||
if (newLeader == fme)
|
||||
{
|
||||
msg("<b>The target player musn't be yourself.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (fyou == fme)
|
||||
// Perform the switching
|
||||
if (targetFactionCurrentLeader != null)
|
||||
{
|
||||
msg("<b>The target player musn't be yourself.");
|
||||
return;
|
||||
targetFactionCurrentLeader.setRole(Rel.OFFICER);
|
||||
}
|
||||
|
||||
fme.setRole(Rel.OFFICER);
|
||||
fyou.setRole(Rel.LEADER);
|
||||
newLeader.setFaction(targetFaction);
|
||||
newLeader.setRole(Rel.LEADER);
|
||||
|
||||
// Inform all players
|
||||
for (FPlayer fplayer : FPlayers.i.getOnline())
|
||||
{
|
||||
fplayer.msg("%s<i> gave %s<i> the leadership of %s", fme.describeTo(fplayer, true), fyou.describeTo(fplayer), myFaction.describeTo(fplayer));
|
||||
fplayer.msg("%s<i> gave %s<i> the leadership of %s", RelationUtil.describeThatToMe(fme, fplayer, true), newLeader.describeTo(fplayer), targetFaction.describeTo(fplayer));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user