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

75 lines
2.2 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;
import com.massivecraft.factions.FPerm;
2013-04-09 13:00:09 +02:00
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.Rel;
2013-04-25 13:25:15 +02:00
import com.massivecraft.factions.cmd.req.ReqFactionsEnabled;
import com.massivecraft.factions.cmd.req.ReqHasFaction;
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
{
this.addAliases("unclaimall");
2011-10-09 20:10:19 +02:00
2013-04-25 13:25:15 +02:00
this.addRequirements(ReqFactionsEnabled.get());
2013-04-16 10:11:59 +02:00
this.addRequirements(ReqHasPerm.get(Perm.UNCLAIM_ALL.node));
this.addRequirements(ReqHasFaction.get());
this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER));
2011-10-09 20:10:19 +02:00
}
@Override
public void perform()
{
// Args
Faction faction = usenderFaction;
Faction newFaction = FactionColls.get().get(faction).getNone();
// FPerm
if (!FPerm.TERRITORY.has(usender, faction, true)) return;
// 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
2013-04-25 12:04:01 +02:00
usenderFaction.msg("%s<i> unclaimed <h>%d <i>of your <h>%d <i>faction land. You now have <h>%d <i>land claimed.", usender.describeTo(usenderFaction, true), countSuccess, countTotal, countFail);
// Log
if (MConf.get().logLandUnclaims)
{
Factions.get().log(usender.getName()+" unclaimed everything for the faction: "+usenderFaction.getName());
}
2011-10-09 20:10:19 +02:00
}
}