Added a permanent power command

This commit is contained in:
Olof Larsson
2011-10-22 18:12:15 +02:00
parent 7ebed6db9c
commit 2ac96f4278
6 changed files with 73 additions and 0 deletions

View File

@ -169,6 +169,7 @@ public class CmdHelp extends FCommand
pageLines.add(p.txt.parse("<i>More commands for server admins:"));
pageLines.add( p.cmdBase.cmdPeaceful.getUseageTemplate(true) );
pageLines.add( p.cmdBase.cmdPermanent.getUseageTemplate(true) );
pageLines.add( p.cmdBase.cmdPermanentPower.getUseageTemplate(true) );
pageLines.add(p.txt.parse("<i>Peaceful factions are protected from PvP and land capture."));
pageLines.add( p.cmdBase.cmdLock.getUseageTemplate(true) );
pageLines.add( p.cmdBase.cmdReload.getUseageTemplate(true) );

View File

@ -0,0 +1,50 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.struct.Permission;
public class CmdPermanentPower extends FCommand
{
public CmdPermanentPower()
{
super();
this.aliases.add("permanentpower");
this.requiredArgs.add("faction");
this.optionalArgs.put("power", "reset");
this.permission = Permission.SET_PERMANENTPOWER.node;
this.disableOnLock = true;
senderMustBePlayer = false;
senderMustBeMember = false;
senderMustBeModerator = false;
senderMustBeAdmin = false;
}
@Override
public void perform()
{
Faction targetFaction = this.argAsFaction(0);
if (targetFaction == null) return;
Integer targetPower = this.argAsInt(1);
targetFaction.setPermanentPower(targetPower);
String change = "removed permanentpower status from";
if(targetFaction.hasPermanentPower())
{
change = "added permanentpower status to";
}
msg("<i>You %s <h>%s<i>.", change, targetFaction.describeTo(fme));
// Inform all players
for (FPlayer fplayer : targetFaction.getFPlayersWhereOnline(true))
{
fplayer.msg((fme == null ? "A server admin" : fme.describeTo(fplayer, true))+"<i> "+change+" your faction.");
}
}
}

View File

@ -33,6 +33,7 @@ public class FCmdRoot extends FCommand
public CmdOwnerList cmdOwnerList = new CmdOwnerList();
public CmdPeaceful cmdPeaceful = new CmdPeaceful();
public CmdPermanent cmdPermanent = new CmdPermanent();
public CmdPermanentPower cmdPermanentPower = new CmdPermanentPower();
public CmdPower cmdPower = new CmdPower();
public CmdRelationAlly cmdRelationAlly = new CmdRelationAlly();
public CmdRelationEnemy cmdRelationEnemy = new CmdRelationEnemy();
@ -98,6 +99,7 @@ public class FCmdRoot extends FCommand
this.addSubCommand(this.cmdOwnerList);
this.addSubCommand(this.cmdPeaceful);
this.addSubCommand(this.cmdPermanent);
this.addSubCommand(this.cmdPermanentPower);
this.addSubCommand(this.cmdPower);
this.addSubCommand(this.cmdRelationAlly);
this.addSubCommand(this.cmdRelationEnemy);