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

@ -26,6 +26,7 @@ permissions:
factions.kit.halfmod: true
factions.disband.any: true
factions.setpermanent: true
factions.setpermanentpower: true
factions.setpeaceful: true
factions.sethome.any: true
factions.money.*: true
@ -175,6 +176,8 @@ permissions:
description: designate a faction as peaceful
factions.setpermanent:
description: designate a faction as permanent
factions.setpermanentpower:
description: set permanent power for a faction
factions.power:
description: show player power info
factions.power.any:

View File

@ -129,6 +129,12 @@ public class Faction extends Entity implements EconomyParticipator
return Econ.getMethod().getAccount(aid);
}
// FIELD: permanentPower
private Integer permanentPower;
public Integer getPermanentPower() { return this.permanentPower; }
public void setPermanentPower(Integer permanentPower) { this.permanentPower = permanentPower; }
public boolean hasPermanentPower() { return this.permanentPower != null; }
// -------------------------------------------- //
// Construct
// -------------------------------------------- //
@ -247,6 +253,11 @@ public class Faction extends Entity implements EconomyParticipator
//----------------------------------------------//
public double getPower()
{
if (this.hasPermanentPower())
{
return this.getPermanentPower();
}
double ret = 0;
for (FPlayer fplayer : this.getFPlayers())
{
@ -261,6 +272,11 @@ public class Faction extends Entity implements EconomyParticipator
public double getPowerMax()
{
if (this.hasPermanentPower())
{
return this.getPermanentPower();
}
double ret = 0;
for (FPlayer fplayer : this.getFPlayers())
{

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);

View File

@ -45,6 +45,7 @@ public enum Permission
OWNERLIST("ownerlist"),
SET_PEACEFUL("setpeaceful"),
SET_PERMANENT("setpermanent"),
SET_PERMANENTPOWER("setpermanentpower"),
POWER("power"),
POWER_ANY("power.any"),
RELATION("relation"),