Factions3/src/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java

59 lines
1.7 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
2013-04-09 13:15:25 +02:00
import com.massivecraft.factions.ConfServer;
2013-04-09 13:00:09 +02:00
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast;
import com.massivecraft.factions.entity.BoardColls;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.event.FactionsEventLandUnclaimAll;
2011-10-09 20:10:19 +02:00
import com.massivecraft.factions.integration.Econ;
2013-04-16 10:11:59 +02:00
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
2011-10-09 20:10:19 +02:00
2013-04-10 13:12:22 +02:00
public class CmdFactionsUnclaimall extends FCommand
2011-10-09 20:10:19 +02:00
{
2013-04-10 13:12:22 +02:00
public CmdFactionsUnclaimall()
2011-10-09 20:10:19 +02:00
{
2013-04-16 10:11:59 +02:00
this.addAliases("unclaimall", "declaimall");
2011-10-09 20:10:19 +02:00
2013-04-16 10:11:59 +02:00
this.addRequirements(ReqHasPerm.get(Perm.UNCLAIM_ALL.node));
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
2011-10-09 20:10:19 +02:00
}
@Override
public void perform()
{
// TODO: Put this as a listener and not in here!
2013-04-22 09:37:53 +02:00
if (Econ.isEnabled(myFaction))
2011-10-12 18:48:47 +02:00
{
double refund = Econ.calculateTotalLandRefund(myFaction.getLandCount());
2013-04-09 13:15:25 +02:00
if(ConfServer.bankEnabled && ConfServer.bankFactionPaysLandCosts)
{
2013-04-19 09:50:33 +02:00
if ( ! Econ.modifyMoney(myFaction, refund, "unclaim all faction land")) return;
}
else
{
2013-04-19 09:50:33 +02:00
if ( ! Econ.modifyMoney(fme, refund, "unclaim all faction land")) return;
}
2011-10-12 18:48:47 +02:00
}
2011-10-09 20:10:19 +02:00
// Event
FactionsEventLandUnclaimAll event = new FactionsEventLandUnclaimAll(sender, myFaction);
event.run();
// TODO: this event cannot be cancelled yet.
// Apply
BoardColls.get().removeAll(myFaction);
// Inform
2011-10-21 19:20:33 +02:00
myFaction.msg("%s<i> unclaimed ALL of your faction's land.", fme.describeTo(myFaction, true));
if (MConf.get().logLandUnclaims)
{
Factions.get().log(fme.getName()+" unclaimed everything for the faction: "+myFaction.getTag());
}
2011-10-09 20:10:19 +02:00
}
}