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

68 lines
1.8 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 java.util.Set;
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.BoardColl;
import com.massivecraft.factions.entity.BoardColls;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColls;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.event.FactionsEventChunkChange;
2013-04-16 10:11:59 +02:00
import com.massivecraft.mcore.cmd.req.ReqHasPerm;
import com.massivecraft.mcore.ps.PS;
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()
{
// Args
Faction faction = myFaction;
Faction newFaction = FactionColls.get().get(faction).getNone();
// Apply
BoardColl boardColl = BoardColls.get().get(faction);
Set<PS> chunks = boardColl.getChunks(faction);
int countTotal = chunks.size();
int countSuccess = 0;
int countFail = 0;
for (PS chunk : chunks)
2011-10-12 18:48:47 +02:00
{
FactionsEventChunkChange event = new FactionsEventChunkChange(sender, chunk, newFaction);
event.run();
if (event.isCancelled())
{
countFail++;
}
else
{
countSuccess++;
boardColl.setFactionAt(chunk, newFaction);
}
2011-10-12 18:48:47 +02:00
}
// Inform
myFaction.msg("%s<i> unclaimed <h>5 <i> of your <h>200 <i>faction land. You now have <h>23 <i>land left.", fme.describeTo(myFaction, true), countSuccess, countTotal, countFail);
// Log
if (MConf.get().logLandUnclaims)
{
Factions.get().log(fme.getName()+" unclaimed everything for the faction: "+myFaction.getTag());
}
2011-10-09 20:10:19 +02:00
}
}