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

92 lines
2.4 KiB
Java
Raw Normal View History

package com.massivecraft.factions.cmd;
import java.util.Set;
import com.massivecraft.factions.Perm;
import com.massivecraft.factions.entity.Board;
import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.massivecore.cmd.arg.ARWorldId;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
2014-11-19 10:30:44 +01:00
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
import com.massivecraft.massivecore.mixin.Mixin;
import com.massivecraft.massivecore.ps.PS;
import com.massivecraft.massivecore.util.MUtil;
2014-11-19 10:30:44 +01:00
public class CmdFactionsSetAll extends CmdFactionsSetXAll
{
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
2014-11-19 10:30:44 +01:00
public CmdFactionsSetAll(boolean claim)
{
2014-11-19 10:30:44 +01:00
// Super
super(claim);
// Aliases
2014-11-19 10:30:44 +01:00
this.addAliases("all");
// Requirements
2014-11-19 10:30:44 +01:00
this.addRequirements(ReqIsPlayer.get());
String node = claim ? Perm.CLAIM_ALL.node : Perm.UNCLAIM_ALL.node;
this.addRequirements(ReqHasPerm.get(node));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public Set<PS> getChunks()
{
2014-11-19 10:30:44 +01:00
// World
String word = (this.isClaim() ? "claim" : "unclaim");
// Create Ret
Set<PS> chunks = null;
// Args
Faction oldFaction = this.getOldFaction();
if (oldFaction == null) return null;
if (MUtil.list("a", "al", "all").contains(this.arg(0).toLowerCase()))
{
chunks = BoardColl.get().getChunks(oldFaction);
2014-11-19 10:30:44 +01:00
this.setFormatOne("<h>%s<i> %s <h>%d <i>chunk using " + word + " all.");
this.setFormatMany("<h>%s<i> %s <h>%d <i>chunks using " + word + " all.");
}
else
{
String worldId = null;
if (MUtil.list("map").contains(this.arg(0).toLowerCase()))
{
if (me != null)
{
worldId = me.getWorld().getName();
}
else
{
msg("<b>You must specify which map from console.");
return null;
}
}
else
{
worldId = this.arg(0, ARWorldId.get());
if (worldId == null) return null;
}
Board board = BoardColl.get().get(worldId);
chunks = board.getChunks(oldFaction);
String worldDisplayName = Mixin.getWorldDisplayName(worldId);
2014-11-19 10:30:44 +01:00
this.setFormatOne("<h>%s<i> %s <h>%d <i>chunk using " + word + " <h>" + worldDisplayName + "<i>.");
this.setFormatMany("<h>%s<i> %s <h>%d <i>chunks using " + word + " <h>" + worldDisplayName + "<i>.");
}
// Return Ret
return chunks;
}
}