Saber-Factions/src/com/massivecraft/factions/cmd/CmdUnclaimall.java

86 lines
2.3 KiB
Java
Raw Normal View History

2011-10-09 21:57:43 +02:00
package com.massivecraft.factions.cmd;
2011-10-09 20:10:19 +02:00
import com.massivecraft.factions.Board;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission;
public class CmdUnclaimall extends FCommand
{
public CmdUnclaimall()
{
this.aliases.add("unclaimall");
this.aliases.add("declaimall");
//this.requiredArgs.add("");
//this.optionalArgs.put("", "");
2011-10-09 21:57:43 +02:00
this.permission = Permission.UNCLAIM_ALL.node;
this.disableOnLock = true;
2011-10-09 20:10:19 +02:00
senderMustBePlayer = true;
senderMustBeMember = false;
senderMustBeModerator = true;
senderMustBeAdmin = false;
}
@Override
public void perform()
{
String moneyBack = "<i>";
if (Econ.enabled())
{
double refund = Econ.calculateTotalLandRefund(myFaction.getLandRounded());
// a real refund
if (refund > 0.0)
{
if(Conf.bankFactionPaysLandCosts)
{
Faction faction = myFaction;
faction.addMoney(refund);
moneyBack = " "+faction.getTag()+" <i>received a refund of <h>"+Econ.moneyString(refund)+"<i>.";
}
else
{
Econ.addMoney(fme.getName(), refund);
moneyBack = " They received a refund of <h>"+Econ.moneyString(refund)+"<i>.";
}
}
// wait, you're charging people to unclaim land? outrageous
else if (refund < 0.0)
{
if(Conf.bankFactionPaysLandCosts)
{
Faction faction = myFaction;
if(!faction.removeMoney(-refund))
{
2011-10-10 13:40:24 +02:00
msg("<b>Unclaiming all faction land will cost <h>"+Econ.moneyString(-refund)+"<b>, which your faction can't currently afford.");
2011-10-09 20:10:19 +02:00
return;
}
moneyBack = " It cost "+faction.getTag()+" "+Econ.moneyString(refund)+".";
}
else
{
if (!Econ.deductMoney(fme.getName(), -refund))
{
2011-10-10 13:40:24 +02:00
msg("<b>Unclaiming all faction land will cost <h>"+Econ.moneyString(-refund)+"<b>, which you can't currently afford.");
2011-10-09 20:10:19 +02:00
return;
}
moneyBack = "<i> It cost them <h>"+Econ.moneyString(refund)+"<i>.";
}
moneyBack = "<i> It cost them <h>"+Econ.moneyString(refund)+"<i>.";
}
// no refund
else
{
moneyBack = "";
}
}
Board.unclaimAll(myFaction.getId());
2011-10-10 13:40:24 +02:00
myFaction.msg("%s<i> unclaimed ALL of your faction's land."+moneyBack, fme.getNameAndRelevant(myFaction));
2011-10-09 20:10:19 +02:00
}
}