2014-10-13 15:14:34 +02:00
|
|
|
package com.massivecraft.factions.cmd;
|
|
|
|
|
2015-05-06 17:04:35 +02:00
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
2014-10-13 15:14:34 +02:00
|
|
|
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;
|
2015-02-12 12:00:55 +01:00
|
|
|
import com.massivecraft.massivecore.MassiveException;
|
2015-11-06 02:10:29 +01:00
|
|
|
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
|
2014-10-14 08:56:07 +02:00
|
|
|
import com.massivecraft.massivecore.mixin.Mixin;
|
2014-10-13 15:14:34 +02:00
|
|
|
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
|
2014-10-13 15:14:34 +02:00
|
|
|
{
|
2015-05-06 17:04:35 +02:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// CONSTANTS
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
|
|
|
public static final List<String> LIST_ALL = Collections.unmodifiableList(MUtil.list("a", "al", "all"));
|
|
|
|
public static final List<String> LIST_MAP = Collections.singletonList("map");
|
|
|
|
|
2014-10-13 15:14:34 +02:00
|
|
|
// -------------------------------------------- //
|
|
|
|
// CONSTRUCT
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
2014-11-19 10:30:44 +01:00
|
|
|
public CmdFactionsSetAll(boolean claim)
|
2014-10-13 15:14:34 +02:00
|
|
|
{
|
2014-11-19 10:30:44 +01:00
|
|
|
// Super
|
|
|
|
super(claim);
|
|
|
|
|
2014-10-13 15:14:34 +02:00
|
|
|
// Aliases
|
2014-11-19 10:30:44 +01:00
|
|
|
this.addAliases("all");
|
|
|
|
|
2014-10-13 15:14:34 +02:00
|
|
|
// Requirements
|
2014-11-19 10:30:44 +01:00
|
|
|
String node = claim ? Perm.CLAIM_ALL.node : Perm.UNCLAIM_ALL.node;
|
2015-11-06 02:10:29 +01:00
|
|
|
this.addRequirements(RequirementHasPerm.get(node));
|
2014-10-13 15:14:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// -------------------------------------------- //
|
|
|
|
// OVERRIDE
|
|
|
|
// -------------------------------------------- //
|
|
|
|
|
|
|
|
@Override
|
2015-02-12 12:00:55 +01:00
|
|
|
public Set<PS> getChunks() throws MassiveException
|
2014-10-13 15:14:34 +02:00
|
|
|
{
|
2014-11-19 10:30:44 +01:00
|
|
|
// World
|
|
|
|
String word = (this.isClaim() ? "claim" : "unclaim");
|
|
|
|
|
2014-10-13 15:14:34 +02:00
|
|
|
// Create Ret
|
|
|
|
Set<PS> chunks = null;
|
|
|
|
|
|
|
|
// Args
|
|
|
|
Faction oldFaction = this.getOldFaction();
|
|
|
|
|
2015-05-06 17:04:35 +02:00
|
|
|
if (LIST_ALL.contains(this.argAt(0).toLowerCase()))
|
2014-10-13 15:14:34 +02:00
|
|
|
{
|
|
|
|
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.");
|
2014-10-13 15:14:34 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
String worldId = null;
|
2015-05-06 17:04:35 +02:00
|
|
|
if (LIST_MAP.contains(this.argAt(0).toLowerCase()))
|
2014-10-13 15:14:34 +02:00
|
|
|
{
|
|
|
|
if (me != null)
|
|
|
|
{
|
|
|
|
worldId = me.getWorld().getName();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
msg("<b>You must specify which map from console.");
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-05-06 17:04:35 +02:00
|
|
|
worldId = this.argAt(0);
|
2014-10-13 15:14:34 +02:00
|
|
|
if (worldId == null) return null;
|
|
|
|
}
|
|
|
|
Board board = BoardColl.get().get(worldId);
|
|
|
|
chunks = board.getChunks(oldFaction);
|
2014-10-14 08:56:07 +02:00
|
|
|
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>.");
|
2014-10-13 15:14:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Return Ret
|
|
|
|
return chunks;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|