Factions/src/com/massivecraft/factions/cmd/CmdKick.java

100 lines
2.9 KiB
Java
Raw Normal View History

2011-10-09 21:57:43 +02:00
package com.massivecraft.factions.cmd;
2011-07-18 22:06:02 +02:00
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
2011-07-18 22:06:02 +02:00
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.FFlag;
import com.massivecraft.factions.struct.Permission;
2011-10-09 20:10:19 +02:00
public class CmdKick extends FCommand
{
2011-10-09 20:10:19 +02:00
public CmdKick()
{
super();
this.aliases.add("kick");
this.requiredArgs.add("player name");
//this.optionalArgs.put("", "");
2011-10-09 21:57:43 +02:00
this.permission = Permission.KICK.node;
this.disableOnLock = false;
senderMustBePlayer = true;
senderMustBeMember = false;
2011-10-23 17:55:53 +02:00
senderMustBeOfficer = true;
senderMustBeLeader = false;
}
@Override
public void perform()
{
FPlayer you = this.argAsBestFPlayerMatch(0);
if (you == null) return;
if (fme == you)
{
2011-10-10 13:40:24 +02:00
msg("<b>You cannot kick yourself.");
2011-10-10 14:21:22 +02:00
msg("<i>You might want to: %s", p.cmdBase.cmdLeave.getUseageTemplate(false));
return;
}
Faction yourFaction = you.getFaction();
// players with admin-level "disband" permission can bypass these requirements
2011-10-09 21:57:43 +02:00
if ( ! Permission.KICK_ANY.has(sender))
{
if (yourFaction != myFaction)
{
2011-10-21 19:20:33 +02:00
msg("%s<b> is not a member of %s", you.describeTo(fme, true), myFaction.describeTo(fme));
return;
}
2011-10-24 11:07:06 +02:00
if (you.getRole().isAtLeast(fme.getRole()))
{
// TODO add more informative messages.
2011-10-10 13:40:24 +02:00
msg("<b>Your rank is too low to kick this player.");
return;
}
if ( ! Conf.canLeaveWithNegativePower && you.getPower() < 0)
{
2011-10-10 13:40:24 +02:00
msg("<b>You cannot kick that member until their power is positive.");
return;
}
}
// if economy is enabled, they're not on the bypass list, and this command has a cost set, make 'em pay
2011-10-12 18:48:47 +02:00
if ( ! payForCommand(Conf.econCostKick, "to kick someone from the faction", "for kicking someone from the faction")) return;
2011-10-21 19:20:33 +02:00
yourFaction.msg("%s<i> kicked %s<i> from the faction! :O", fme.describeTo(yourFaction, true), you.describeTo(yourFaction, true));
you.msg("%s<i> kicked you from %s<i>! :O", fme.describeTo(you, true), yourFaction.describeTo(you));
if (yourFaction != myFaction)
{
2011-10-21 19:20:33 +02:00
fme.msg("<i>You kicked %s<i> from the faction %s<i>!", you.describeTo(fme), yourFaction.describeTo(fme));
}
yourFaction.deinvite(you);
you.resetFactionData();
if (Conf.logFactionKick)
P.p.log(fme.getName()+" kicked "+you.getName()+" from the faction: "+yourFaction.getTag());
if (yourFaction.getFPlayers().isEmpty() && !yourFaction.getFlag(FFlag.PERMANENT))
{
// Remove this faction
for (FPlayer fplayer : FPlayers.i.getOnline())
{
2011-10-10 13:40:24 +02:00
fplayer.msg("The faction %s<i> was disbanded.", yourFaction.getTag(fplayer));
}
yourFaction.detach();
if (Conf.logFactionDisband)
P.p.log("The faction "+yourFaction.getTag()+" ("+yourFaction.getId()+") was disbanded since the last player was kicked by "+(senderIsConsole ? "console command" : fme.getName())+".");
}
}
}