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

79 lines
2.2 KiB
Java
Raw Normal View History

package com.massivecraft.factions.cmd;
import java.util.Set;
import com.massivecraft.factions.entity.Faction;
2014-11-19 10:30:44 +01:00
import com.massivecraft.factions.entity.FactionColl;
2015-02-12 12:00:55 +01:00
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.ps.PS;
public abstract class CmdFactionsSetX extends FactionsCommand
{
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private String formatOne = null;
public String getFormatOne() { return this.formatOne; }
public void setFormatOne(String formatOne) { this.formatOne = formatOne; }
private String formatMany = null;
public String getFormatMany() { return this.formatMany; }
public void setFormatMany(String formatMany) { this.formatMany = formatMany; }
2014-11-19 10:30:44 +01:00
private boolean claim = true;
public boolean isClaim() { return this.claim; }
public void setClaim(boolean claim) { this.claim = claim; }
private int factionArgIndex = 0;
public int getFactionArgIndex() { return this.factionArgIndex; }
public void setFactionArgIndex(int factionArgIndex) { this.factionArgIndex = factionArgIndex; }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsSetX(boolean claim)
{
this.setClaim(claim);
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
2015-02-12 12:00:55 +01:00
public void perform() throws MassiveException
{
// Args
final Faction newFaction = this.getNewFaction();
final Set<PS> chunks = this.getChunks();
// Apply / Inform
msender.tryClaim(newFaction, chunks, this.getFormatOne(), this.getFormatMany());
}
// -------------------------------------------- //
// ABSTRACT
// -------------------------------------------- //
2015-02-12 12:00:55 +01:00
public abstract Set<PS> getChunks() throws MassiveException;
// -------------------------------------------- //
// EXTRAS
// -------------------------------------------- //
2015-02-12 12:00:55 +01:00
public Faction getNewFaction() throws MassiveException
{
2014-11-19 10:30:44 +01:00
if (this.isClaim())
{
2015-05-06 17:04:35 +02:00
return this.readArgAt(this.getFactionArgIndex(), msenderFaction);
2014-11-19 10:30:44 +01:00
}
else
{
return FactionColl.get().getNone();
}
}
}