Split up set in to claim and unclaim

This commit is contained in:
Olof Larsson 2014-11-19 10:30:44 +01:00
parent 2240696c98
commit c058cd7ca5
16 changed files with 273 additions and 146 deletions

View File

@ -15,6 +15,13 @@ public enum Perm
ACCESS_PLAYER("access.player"), ACCESS_PLAYER("access.player"),
ACCESS_FACTION("access.faction"), ACCESS_FACTION("access.faction"),
ADMIN("admin"), ADMIN("admin"),
CLAIM("claim"),
CLAIM_ONE("claim.one"),
CLAIM_AUTO("claim.auto"),
CLAIM_FILL("claim.fill"),
CLAIM_SQUARE("claim.square"),
CLAIM_CIRCLE("claim.circle"),
CLAIM_ALL("claim.all"),
CREATE("create"), CREATE("create"),
DEMOTE("demote"), DEMOTE("demote"),
DESCRIPTION("description"), DESCRIPTION("description"),
@ -52,17 +59,17 @@ public enum Perm
RELATION("relation"), RELATION("relation"),
SEECHUNK("seechunk"), SEECHUNK("seechunk"),
SEECHUNKOLD("seechunkold"), SEECHUNKOLD("seechunkold"),
SET("set"),
SET_ONE("set.one"),
SET_AUTO("set.auto"),
SET_FILL("set.fill"),
SET_SQUARE("set.square"),
SET_CIRCLE("set.circle"),
SET_TRANSFER("set.transfer"),
SETHOME("sethome"), SETHOME("sethome"),
NAME("name"), NAME("name"),
TITLE("title"), TITLE("title"),
TITLE_COLOR("title.color"), TITLE_COLOR("title.color"),
UNCLAIM("unclaim"),
UNCLAIM_ONE("unclaim.one"),
UNCLAIM_AUTO("unclaim.auto"),
UNCLAIM_FILL("unclaim.fill"),
UNCLAIM_SQUARE("unclaim.square"),
UNCLAIM_CIRCLE("unclaim.circle"),
UNCLAIM_ALL("unclaim.all"),
UNSETHOME("unsethome"), UNSETHOME("unsethome"),
VERSION("version"), VERSION("version"),

View File

@ -25,7 +25,6 @@ public class CmdFactions extends FactionsCommand
public CmdFactionsName cmdFactionsName = new CmdFactionsName(); public CmdFactionsName cmdFactionsName = new CmdFactionsName();
public CmdFactionsDescription cmdFactionsDescription = new CmdFactionsDescription(); public CmdFactionsDescription cmdFactionsDescription = new CmdFactionsDescription();
public CmdFactionsMotd cmdFactionsMotd = new CmdFactionsMotd(); public CmdFactionsMotd cmdFactionsMotd = new CmdFactionsMotd();
public CmdFactionsSet cmdFactionsSet = new CmdFactionsSet();
public CmdFactionsSethome cmdFactionsSethome = new CmdFactionsSethome(); public CmdFactionsSethome cmdFactionsSethome = new CmdFactionsSethome();
public CmdFactionsUnsethome cmdFactionsUnsethome = new CmdFactionsUnsethome(); public CmdFactionsUnsethome cmdFactionsUnsethome = new CmdFactionsUnsethome();
public CmdFactionsInvite cmdFactionsInvite = new CmdFactionsInvite(); public CmdFactionsInvite cmdFactionsInvite = new CmdFactionsInvite();
@ -36,9 +35,10 @@ public class CmdFactions extends FactionsCommand
public CmdFactionsOfficer cmdFactionsOfficer = new CmdFactionsOfficer(); public CmdFactionsOfficer cmdFactionsOfficer = new CmdFactionsOfficer();
public CmdFactionsLeader cmdFactionsLeader = new CmdFactionsLeader(); public CmdFactionsLeader cmdFactionsLeader = new CmdFactionsLeader();
public CmdFactionsMoney cmdFactionsMoney = new CmdFactionsMoney(); public CmdFactionsMoney cmdFactionsMoney = new CmdFactionsMoney();
public CmdFactionsXPlaceholder cmdFactionsTax = new CmdFactionsXPlaceholder("FactionsTax", "tax");
public CmdFactionsSeeChunk cmdFactionsSeeChunk = new CmdFactionsSeeChunk(); public CmdFactionsSeeChunk cmdFactionsSeeChunk = new CmdFactionsSeeChunk();
public CmdFactionsSeeChunkOld cmdFactionsSeeChunkOld = new CmdFactionsSeeChunkOld(); public CmdFactionsSeeChunkOld cmdFactionsSeeChunkOld = new CmdFactionsSeeChunkOld();
public CmdFactionsClaim cmdFactionsClaim = new CmdFactionsClaim();
public CmdFactionsUnclaim cmdFactionsUnclaim = new CmdFactionsUnclaim();
public CmdFactionsAccess cmdFactionsAccess = new CmdFactionsAccess(); public CmdFactionsAccess cmdFactionsAccess = new CmdFactionsAccess();
public CmdFactionsRelationAlly cmdFactionsRelationAlly = new CmdFactionsRelationAlly(); public CmdFactionsRelationAlly cmdFactionsRelationAlly = new CmdFactionsRelationAlly();
public CmdFactionsRelationTruce cmdFactionsRelationTruce = new CmdFactionsRelationTruce(); public CmdFactionsRelationTruce cmdFactionsRelationTruce = new CmdFactionsRelationTruce();
@ -46,10 +46,11 @@ public class CmdFactions extends FactionsCommand
public CmdFactionsRelationEnemy cmdFactionsRelationEnemy = new CmdFactionsRelationEnemy(); public CmdFactionsRelationEnemy cmdFactionsRelationEnemy = new CmdFactionsRelationEnemy();
public CmdFactionsPerm cmdFactionsPerm = new CmdFactionsPerm(); public CmdFactionsPerm cmdFactionsPerm = new CmdFactionsPerm();
public CmdFactionsFlag cmdFactionsFlag = new CmdFactionsFlag(); public CmdFactionsFlag cmdFactionsFlag = new CmdFactionsFlag();
public CmdFactionsDisband cmdFactionsDisband = new CmdFactionsDisband();
public CmdFactionsExpansions cmdFactionsExpansions = new CmdFactionsExpansions(); public CmdFactionsExpansions cmdFactionsExpansions = new CmdFactionsExpansions();
public CmdFactionsXPlaceholder cmdFactionsTax = new CmdFactionsXPlaceholder("FactionsTax", "tax");
public CmdFactionsXPlaceholder cmdFactionsDynmap = new CmdFactionsXPlaceholder("FactionsDynmap", "dynmap"); public CmdFactionsXPlaceholder cmdFactionsDynmap = new CmdFactionsXPlaceholder("FactionsDynmap", "dynmap");
public CmdFactionsAdmin cmdFactionsAdmin = new CmdFactionsAdmin(); public CmdFactionsAdmin cmdFactionsAdmin = new CmdFactionsAdmin();
public CmdFactionsDisband cmdFactionsDisband = new CmdFactionsDisband();
public CmdFactionsPowerBoost cmdFactionsPowerBoost = new CmdFactionsPowerBoost(); public CmdFactionsPowerBoost cmdFactionsPowerBoost = new CmdFactionsPowerBoost();
public VersionCommand cmdFactionsVersion = new VersionCommand(Factions.get(), Perm.VERSION.node, "v", "version"); public VersionCommand cmdFactionsVersion = new VersionCommand(Factions.get(), Perm.VERSION.node, "v", "version");
@ -72,7 +73,6 @@ public class CmdFactions extends FactionsCommand
this.addSubCommand(this.cmdFactionsName); this.addSubCommand(this.cmdFactionsName);
this.addSubCommand(this.cmdFactionsDescription); this.addSubCommand(this.cmdFactionsDescription);
this.addSubCommand(this.cmdFactionsMotd); this.addSubCommand(this.cmdFactionsMotd);
this.addSubCommand(this.cmdFactionsSet);
this.addSubCommand(this.cmdFactionsSethome); this.addSubCommand(this.cmdFactionsSethome);
this.addSubCommand(this.cmdFactionsUnsethome); this.addSubCommand(this.cmdFactionsUnsethome);
this.addSubCommand(this.cmdFactionsInvite); this.addSubCommand(this.cmdFactionsInvite);
@ -83,9 +83,10 @@ public class CmdFactions extends FactionsCommand
this.addSubCommand(this.cmdFactionsOfficer); this.addSubCommand(this.cmdFactionsOfficer);
this.addSubCommand(this.cmdFactionsLeader); this.addSubCommand(this.cmdFactionsLeader);
this.addSubCommand(this.cmdFactionsMoney); this.addSubCommand(this.cmdFactionsMoney);
this.addSubCommand(this.cmdFactionsTax);
this.addSubCommand(this.cmdFactionsSeeChunk); this.addSubCommand(this.cmdFactionsSeeChunk);
this.addSubCommand(this.cmdFactionsSeeChunkOld); this.addSubCommand(this.cmdFactionsSeeChunkOld);
this.addSubCommand(this.cmdFactionsClaim);
this.addSubCommand(this.cmdFactionsUnclaim);
this.addSubCommand(this.cmdFactionsAccess); this.addSubCommand(this.cmdFactionsAccess);
this.addSubCommand(this.cmdFactionsRelationAlly); this.addSubCommand(this.cmdFactionsRelationAlly);
this.addSubCommand(this.cmdFactionsRelationTruce); this.addSubCommand(this.cmdFactionsRelationTruce);
@ -93,18 +94,17 @@ public class CmdFactions extends FactionsCommand
this.addSubCommand(this.cmdFactionsRelationEnemy); this.addSubCommand(this.cmdFactionsRelationEnemy);
this.addSubCommand(this.cmdFactionsPerm); this.addSubCommand(this.cmdFactionsPerm);
this.addSubCommand(this.cmdFactionsFlag); this.addSubCommand(this.cmdFactionsFlag);
this.addSubCommand(this.cmdFactionsDisband);
this.addSubCommand(this.cmdFactionsExpansions); this.addSubCommand(this.cmdFactionsExpansions);
this.addSubCommand(this.cmdFactionsTax);
this.addSubCommand(this.cmdFactionsDynmap); this.addSubCommand(this.cmdFactionsDynmap);
this.addSubCommand(this.cmdFactionsAdmin); this.addSubCommand(this.cmdFactionsAdmin);
this.addSubCommand(this.cmdFactionsDisband);
this.addSubCommand(this.cmdFactionsPowerBoost); this.addSubCommand(this.cmdFactionsPowerBoost);
this.addSubCommand(this.cmdFactionsVersion); this.addSubCommand(this.cmdFactionsVersion);
// Deprecated Commands // Deprecated Commands
this.addSubCommand(new CmdFactionsXDeprecated(this.cmdFactionsSet, "claim")); this.addSubCommand(new CmdFactionsXDeprecated(this.cmdFactionsClaim.cmdFactionsClaimAuto, "autoclaim"));
this.addSubCommand(new CmdFactionsXDeprecated(this.cmdFactionsSet, "unclaim")); this.addSubCommand(new CmdFactionsXDeprecated(this.cmdFactionsUnclaim.cmdFactionsUnclaimAll, "unclaimall"));
this.addSubCommand(new CmdFactionsXDeprecated(this.cmdFactionsSet, "autoclaim"));
this.addSubCommand(new CmdFactionsXDeprecated(this.cmdFactionsSet, "unclaimall"));
this.addSubCommand(new CmdFactionsXDeprecated(this.cmdFactionsFlag, "open")); this.addSubCommand(new CmdFactionsXDeprecated(this.cmdFactionsFlag, "open"));
this.addSubCommand(new CmdFactionsXDeprecated(this.cmdFactionsFaction, "show", "who")); this.addSubCommand(new CmdFactionsXDeprecated(this.cmdFactionsFaction, "show", "who"));
} }

View File

@ -0,0 +1,41 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
public class CmdFactionsClaim extends FactionsCommand
{
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
public CmdFactionsSetOne cmdFactionsClaimOne = new CmdFactionsSetOne(true);
public CmdFactionsSetAuto cmdFactionsClaimAuto = new CmdFactionsSetAuto(true);
public CmdFactionsSetFill cmdFactionsClaimFill = new CmdFactionsSetFill(true);
public CmdFactionsSetSquare cmdFactionsClaimSquare = new CmdFactionsSetSquare(true);
public CmdFactionsSetCircle cmdFactionsClaimCircle = new CmdFactionsSetCircle(true);
public CmdFactionsSetAll cmdFactionsClaimAll = new CmdFactionsSetAll(true);
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsClaim()
{
// Aliases
this.addAliases("claim");
// Add SubCommands
this.addSubCommand(this.cmdFactionsClaimOne);
this.addSubCommand(this.cmdFactionsClaimAuto);
this.addSubCommand(this.cmdFactionsClaimFill);
this.addSubCommand(this.cmdFactionsClaimSquare);
this.addSubCommand(this.cmdFactionsClaimCircle);
this.addSubCommand(this.cmdFactionsClaimAll);
// Requirements
this.addRequirements(ReqHasPerm.get(Perm.CLAIM.node));
}
}

View File

@ -1,45 +0,0 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
public class CmdFactionsSet extends FactionsCommand
{
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
public CmdFactionsSetOne cmdFactionsSetOne = new CmdFactionsSetOne();
public CmdFactionsSetAuto cmdFactionsSetAuto = new CmdFactionsSetAuto();
public CmdFactionsSetFill cmdFactionsSetFill = new CmdFactionsSetFill();
public CmdFactionsSetSquare cmdFactionsSetSquare = new CmdFactionsSetSquare();
public CmdFactionsSetCircle cmdFactionsSetCircle = new CmdFactionsSetCircle();
public CmdFactionsSetTransfer cmdFactionsSetTransfer = new CmdFactionsSetTransfer();
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsSet()
{
// Aliases
this.addAliases("s", "set");
// Add SubCommands
this.addSubCommand(this.cmdFactionsSetOne);
this.addSubCommand(this.cmdFactionsSetAuto);
this.addSubCommand(this.cmdFactionsSetFill);
this.addSubCommand(this.cmdFactionsSetSquare);
this.addSubCommand(this.cmdFactionsSetCircle);
this.addSubCommand(this.cmdFactionsSetTransfer);
this.setHelp("Tip: Set faction <h>none <i>to unclaim.");
// Requirements
this.addRequirements(ReqHasPerm.get(Perm.SET.node));
}
}

View File

@ -8,24 +8,30 @@ import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.massivecore.cmd.arg.ARWorldId; import com.massivecraft.massivecore.cmd.arg.ARWorldId;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
import com.massivecraft.massivecore.mixin.Mixin; import com.massivecraft.massivecore.mixin.Mixin;
import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.ps.PS;
import com.massivecraft.massivecore.util.MUtil; import com.massivecraft.massivecore.util.MUtil;
public class CmdFactionsSetTransfer extends CmdFactionsSetXTransfer public class CmdFactionsSetAll extends CmdFactionsSetXAll
{ {
// -------------------------------------------- // // -------------------------------------------- //
// CONSTRUCT // CONSTRUCT
// -------------------------------------------- // // -------------------------------------------- //
public CmdFactionsSetTransfer() public CmdFactionsSetAll(boolean claim)
{ {
// Super
super(claim);
// Aliases // Aliases
this.addAliases("t", "transfer"); this.addAliases("all");
// Requirements // Requirements
this.addRequirements(ReqHasPerm.get(Perm.SET_TRANSFER.node)); this.addRequirements(ReqIsPlayer.get());
String node = claim ? Perm.CLAIM_ALL.node : Perm.UNCLAIM_ALL.node;
this.addRequirements(ReqHasPerm.get(node));
} }
// -------------------------------------------- // // -------------------------------------------- //
@ -35,6 +41,9 @@ public class CmdFactionsSetTransfer extends CmdFactionsSetXTransfer
@Override @Override
public Set<PS> getChunks() public Set<PS> getChunks()
{ {
// World
String word = (this.isClaim() ? "claim" : "unclaim");
// Create Ret // Create Ret
Set<PS> chunks = null; Set<PS> chunks = null;
@ -45,8 +54,8 @@ public class CmdFactionsSetTransfer extends CmdFactionsSetXTransfer
if (MUtil.list("a", "al", "all").contains(this.arg(0).toLowerCase())) if (MUtil.list("a", "al", "all").contains(this.arg(0).toLowerCase()))
{ {
chunks = BoardColl.get().getChunks(oldFaction); chunks = BoardColl.get().getChunks(oldFaction);
this.setFormatOne("<h>%s<i> %s <h>%d <i>chunk using transfer all."); this.setFormatOne("<h>%s<i> %s <h>%d <i>chunk using " + word + " all.");
this.setFormatMany("<h>%s<i> %s <h>%d <i>chunks using transfer all."); this.setFormatMany("<h>%s<i> %s <h>%d <i>chunks using " + word + " all.");
} }
else else
{ {
@ -71,9 +80,8 @@ public class CmdFactionsSetTransfer extends CmdFactionsSetXTransfer
Board board = BoardColl.get().get(worldId); Board board = BoardColl.get().get(worldId);
chunks = board.getChunks(oldFaction); chunks = board.getChunks(oldFaction);
String worldDisplayName = Mixin.getWorldDisplayName(worldId); String worldDisplayName = Mixin.getWorldDisplayName(worldId);
this.setFormatOne("<h>%s<i> %s <h>%d <i>chunk using transfer <h>" + worldDisplayName + "<i>."); 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 transfer <h>" + worldDisplayName + "<i>."); this.setFormatMany("<h>%s<i> %s <h>%d <i>chunks using " + word + " <h>" + worldDisplayName + "<i>.");
} }
// Return Ret // Return Ret

View File

@ -6,6 +6,7 @@ import java.util.Set;
import com.massivecraft.factions.Perm; import com.massivecraft.factions.Perm;
import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.factions.entity.MPerm; import com.massivecraft.factions.entity.MPerm;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer;
@ -14,21 +15,36 @@ import com.massivecraft.massivecore.ps.PS;
public class CmdFactionsSetAuto extends FactionsCommand public class CmdFactionsSetAuto extends FactionsCommand
{ {
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private boolean claim = true;
public boolean isClaim() { return this.claim; }
public void setClaim(boolean claim) { this.claim = claim; }
// -------------------------------------------- // // -------------------------------------------- //
// CONSTRUCT // CONSTRUCT
// -------------------------------------------- // // -------------------------------------------- //
public CmdFactionsSetAuto() public CmdFactionsSetAuto(boolean claim)
{ {
// Fields
this.setClaim(claim);
// Aliases // Aliases
this.addAliases("a", "auto"); this.addAliases("a", "auto");
// Args // Args
if (claim)
{
this.addOptionalArg("faction", "you"); this.addOptionalArg("faction", "you");
}
// Requirements // Requirements
this.addRequirements(ReqIsPlayer.get()); this.addRequirements(ReqIsPlayer.get());
this.addRequirements(ReqHasPerm.get(Perm.SET_AUTO.node)); String node = claim ? Perm.CLAIM_AUTO.node : Perm.UNCLAIM_AUTO.node;
this.addRequirements(ReqHasPerm.get(node));
} }
// -------------------------------------------- // // -------------------------------------------- //
@ -39,7 +55,15 @@ public class CmdFactionsSetAuto extends FactionsCommand
public void perform() public void perform()
{ {
// Args // Args
final Faction newFaction = this.arg(0, ARFaction.get(), msenderFaction); final Faction newFaction;
if (claim)
{
newFaction = this.arg(0, ARFaction.get(), msenderFaction);
}
else
{
newFaction = FactionColl.get().getNone();
}
// Disable? // Disable?
if (newFaction == null || newFaction == msender.getAutoClaimFaction()) if (newFaction == null || newFaction == msender.getAutoClaimFaction())

View File

@ -15,8 +15,11 @@ public class CmdFactionsSetCircle extends CmdFactionsSetXRadius
// CONSTRUCT // CONSTRUCT
// -------------------------------------------- // // -------------------------------------------- //
public CmdFactionsSetCircle() public CmdFactionsSetCircle(boolean claim)
{ {
// Super
super(claim);
// Aliases // Aliases
this.addAliases("c", "circle"); this.addAliases("c", "circle");
@ -26,7 +29,8 @@ public class CmdFactionsSetCircle extends CmdFactionsSetXRadius
// Requirements // Requirements
this.addRequirements(ReqIsPlayer.get()); this.addRequirements(ReqIsPlayer.get());
this.addRequirements(ReqHasPerm.get(Perm.SET_CIRCLE.node)); String node = claim ? Perm.CLAIM_CIRCLE.node : Perm.UNCLAIM_CIRCLE.node;
this.addRequirements(ReqHasPerm.get(node));
} }
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -19,8 +19,11 @@ public class CmdFactionsSetFill extends CmdFactionsSetXSimple
// CONSTRUCT // CONSTRUCT
// -------------------------------------------- // // -------------------------------------------- //
public CmdFactionsSetFill() public CmdFactionsSetFill(boolean claim)
{ {
// Super
super(claim);
// Aliases // Aliases
this.addAliases("f", "fill"); this.addAliases("f", "fill");
@ -30,7 +33,8 @@ public class CmdFactionsSetFill extends CmdFactionsSetXSimple
// Requirements // Requirements
this.addRequirements(ReqIsPlayer.get()); this.addRequirements(ReqIsPlayer.get());
this.addRequirements(ReqHasPerm.get(Perm.SET_FILL.node)); String node = claim ? Perm.CLAIM_FILL.node : Perm.UNCLAIM_FILL.node;
this.addRequirements(ReqHasPerm.get(node));
} }
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -15,14 +15,18 @@ public class CmdFactionsSetOne extends CmdFactionsSetXSimple
// CONSTRUCT // CONSTRUCT
// -------------------------------------------- // // -------------------------------------------- //
public CmdFactionsSetOne() public CmdFactionsSetOne(boolean claim)
{ {
// Super
super(claim);
// Aliases // Aliases
this.addAliases("o", "one"); this.addAliases("o", "one");
// Requirements // Requirements
this.addRequirements(ReqIsPlayer.get()); this.addRequirements(ReqIsPlayer.get());
this.addRequirements(ReqHasPerm.get(Perm.SET_ONE.node)); String node = claim ? Perm.CLAIM_ONE.node : Perm.UNCLAIM_ONE.node;
this.addRequirements(ReqHasPerm.get(node));
} }
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -15,8 +15,11 @@ public class CmdFactionsSetSquare extends CmdFactionsSetXRadius
// CONSTRUCT // CONSTRUCT
// -------------------------------------------- // // -------------------------------------------- //
public CmdFactionsSetSquare() public CmdFactionsSetSquare(boolean claim)
{ {
// Super
super(claim);
// Aliases // Aliases
this.addAliases("s", "square"); this.addAliases("s", "square");
@ -26,7 +29,8 @@ public class CmdFactionsSetSquare extends CmdFactionsSetXRadius
// Requirements // Requirements
this.addRequirements(ReqIsPlayer.get()); this.addRequirements(ReqIsPlayer.get());
this.addRequirements(ReqHasPerm.get(Perm.SET_SQUARE.node)); String node = claim ? Perm.CLAIM_SQUARE.node : Perm.UNCLAIM_SQUARE.node;
this.addRequirements(ReqHasPerm.get(node));
} }
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -4,6 +4,7 @@ import java.util.Set;
import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.FactionColl;
import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.ps.PS;
@ -21,6 +22,23 @@ public abstract class CmdFactionsSetX extends FactionsCommand
public String getFormatMany() { return this.formatMany; } public String getFormatMany() { return this.formatMany; }
public void setFormatMany(String formatMany) { this.formatMany = formatMany; } public void setFormatMany(String formatMany) { this.formatMany = formatMany; }
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
// -------------------------------------------- // // -------------------------------------------- //
@ -43,8 +61,6 @@ public abstract class CmdFactionsSetX extends FactionsCommand
// ABSTRACT // ABSTRACT
// -------------------------------------------- // // -------------------------------------------- //
public abstract int getFactionArgIndex();
public abstract Set<PS> getChunks(); public abstract Set<PS> getChunks();
// -------------------------------------------- // // -------------------------------------------- //
@ -52,8 +68,15 @@ public abstract class CmdFactionsSetX extends FactionsCommand
// -------------------------------------------- // // -------------------------------------------- //
public Faction getNewFaction() public Faction getNewFaction()
{
if (this.isClaim())
{ {
return this.arg(this.getFactionArgIndex(), ARFaction.get(), msenderFaction); return this.arg(this.getFactionArgIndex(), ARFaction.get(), msenderFaction);
} }
else
{
return FactionColl.get().getNone();
}
}
} }

View File

@ -3,28 +3,25 @@ package com.massivecraft.factions.cmd;
import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.arg.ARFaction;
import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.Faction;
public abstract class CmdFactionsSetXTransfer extends CmdFactionsSetX public abstract class CmdFactionsSetXAll extends CmdFactionsSetX
{ {
// -------------------------------------------- // // -------------------------------------------- //
// CONSTRUCT // CONSTRUCT
// -------------------------------------------- // // -------------------------------------------- //
public CmdFactionsSetXTransfer() public CmdFactionsSetXAll(boolean claim)
{ {
// Super
super(claim);
// Args // Args
this.addRequiredArg("all|map"); this.addRequiredArg("all|map");
this.addRequiredArg("old"); this.addRequiredArg("faction");
this.addRequiredArg("new"); if (claim)
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public int getFactionArgIndex()
{ {
return 2; this.addRequiredArg("newfaction");
this.setFactionArgIndex(2);
}
} }
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -10,21 +10,18 @@ public abstract class CmdFactionsSetXRadius extends CmdFactionsSetX
// CONSTRUCT // CONSTRUCT
// -------------------------------------------- // // -------------------------------------------- //
public CmdFactionsSetXRadius() public CmdFactionsSetXRadius(boolean claim)
{ {
// Super
super(claim);
// Args // Args
this.addOptionalArg("radius", "1"); this.addOptionalArg("radius", "1");
this.addOptionalArg("faction", "you"); if (claim)
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public int getFactionArgIndex()
{ {
return 1; this.addOptionalArg("faction", "you");
this.setFactionArgIndex(1);
}
} }
// -------------------------------------------- // // -------------------------------------------- //

View File

@ -6,20 +6,17 @@ public abstract class CmdFactionsSetXSimple extends CmdFactionsSetX
// CONSTRUCT // CONSTRUCT
// -------------------------------------------- // // -------------------------------------------- //
public CmdFactionsSetXSimple() public CmdFactionsSetXSimple(boolean claim)
{ {
// Super
super(claim);
// Args // Args
this.addOptionalArg("faction", "you"); if (claim)
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public int getFactionArgIndex()
{ {
return 0; this.addOptionalArg("faction", "you");
this.setFactionArgIndex(0);
}
} }
} }

View File

@ -0,0 +1,41 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Perm;
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
public class CmdFactionsUnclaim extends FactionsCommand
{
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
public CmdFactionsSetOne cmdFactionsUnclaimOne = new CmdFactionsSetOne(false);
public CmdFactionsSetAuto cmdFactionsUnclaimAuto = new CmdFactionsSetAuto(false);
public CmdFactionsSetFill cmdFactionsUnclaimFill = new CmdFactionsSetFill(false);
public CmdFactionsSetSquare cmdFactionsUnclaimSquare = new CmdFactionsSetSquare(false);
public CmdFactionsSetCircle cmdFactionsUnclaimCircle = new CmdFactionsSetCircle(false);
public CmdFactionsSetAll cmdFactionsUnclaimAll = new CmdFactionsSetAll(false);
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public CmdFactionsUnclaim()
{
// Aliases
this.addAliases("unclaim");
// Add SubCommands
this.addSubCommand(this.cmdFactionsUnclaimOne);
this.addSubCommand(this.cmdFactionsUnclaimAuto);
this.addSubCommand(this.cmdFactionsUnclaimFill);
this.addSubCommand(this.cmdFactionsUnclaimSquare);
this.addSubCommand(this.cmdFactionsUnclaimCircle);
this.addSubCommand(this.cmdFactionsUnclaimAll);
// Requirements
this.addRequirements(ReqHasPerm.get(Perm.UNCLAIM.node));
}
}

View File

@ -15,6 +15,13 @@ permissions:
factions.access.player: {description: grant player access, with the proper fperm, default: false} factions.access.player: {description: grant player access, with the proper fperm, default: false}
factions.access.view: {description: view access, default: false} factions.access.view: {description: view access, default: false}
factions.admin: {description: enable adminmode, default: false} factions.admin: {description: enable adminmode, default: false}
factions.claim: {description: claim faction territory, default: false}
factions.claim.one: {description: claim a single chunk, default: false}
factions.claim.auto: {description: claim as you walk around, default: false}
factions.claim.fill: {description: claim by filling, default: false}
factions.claim.square: {description: claim by square and radius, default: false}
factions.claim.circle: {description: claim by circle and radius, default: false}
factions.claim.all: {description: claim all faction land, default: false}
factions.create: {description: create new faction, default: false} factions.create: {description: create new faction, default: false}
factions.demote: {description: demote lesser members in your faction, default: false} factions.demote: {description: demote lesser members in your faction, default: false}
factions.description: {description: change faction description, default: false} factions.description: {description: change faction description, default: false}
@ -52,17 +59,17 @@ permissions:
factions.relation: {description: set relation wish to another faction, default: false} factions.relation: {description: set relation wish to another faction, default: false}
factions.seechunk: {description: see the chunk you stand in, default: false} factions.seechunk: {description: see the chunk you stand in, default: false}
factions.seechunkold: {description: see the chunk you stand in, default: false} factions.seechunkold: {description: see the chunk you stand in, default: false}
factions.set: {description: set faction territory, default: false}
factions.set.one: {description: set faction for a single chunk, default: false}
factions.set.auto: {description: set faction as you walk around, default: false}
factions.set.fill: {description: set faction by filling, default: false}
factions.set.square: {description: set faction by square and radius, default: false}
factions.set.circle: {description: set faction by circle and radius, default: false}
factions.set.transfer: {description: set faction by transfer, default: false}
factions.sethome: {description: set the faction home, default: false} factions.sethome: {description: set the faction home, default: false}
factions.name: {description: set faction name, default: false} factions.name: {description: set faction name, default: false}
factions.title: {description: set player title, default: false} factions.title: {description: set player title, default: false}
factions.title.color: {description: set player title with color, default: false} factions.title.color: {description: set player title with color, default: false}
factions.unclaim: {description: unclaim faction territory, default: false}
factions.unclaim.one: {description: unclaim a single chunk, default: false}
factions.unclaim.auto: {description: unclaim as you walk around, default: false}
factions.unclaim.fill: {description: unclaim by filling, default: false}
factions.unclaim.square: {description: unclaim by square and radius, default: false}
factions.unclaim.circle: {description: unclaim by circle and radius, default: false}
factions.unclaim.all: {description: unclaim all faction land, default: false}
factions.unsethome: {description: unset faction home, default: false} factions.unsethome: {description: unset faction home, default: false}
factions.version: {description: see plugin version, default: false} factions.version: {description: see plugin version, default: false}
# -------------------------------------------- # # -------------------------------------------- #
@ -75,6 +82,13 @@ permissions:
factions.access.player: true factions.access.player: true
factions.access.view: true factions.access.view: true
factions.admin: true factions.admin: true
factions.claim: true
factions.claim.one: true
factions.claim.auto: true
factions.claim.fill: true
factions.claim.square: true
factions.claim.circle: true
factions.claim.all: true
factions.create: true factions.create: true
factions.demote: true factions.demote: true
factions.description: true factions.description: true
@ -112,17 +126,17 @@ permissions:
factions.relation: true factions.relation: true
factions.seechunk: true factions.seechunk: true
factions.seechunkold: true factions.seechunkold: true
factions.set: true
factions.set.one: true
factions.set.auto: true
factions.set.fill: true
factions.set.square: true
factions.set.circle: true
factions.set.transfer: true
factions.sethome: true factions.sethome: true
factions.name: true factions.name: true
factions.title: true factions.title: true
factions.title.color: true factions.title.color: true
factions.unclaim: true
factions.unclaim.one: true
factions.unclaim.auto: true
factions.unclaim.fill: true
factions.unclaim.square: true
factions.unclaim.circle: true
factions.unclaim.all: true
factions.unsethome: true factions.unsethome: true
factions.version: true factions.version: true
# -------------------------------------------- # # -------------------------------------------- #
@ -158,6 +172,13 @@ permissions:
factions.access.faction: true factions.access.faction: true
factions.access.player: true factions.access.player: true
factions.access.view: true factions.access.view: true
factions.claim: true
factions.claim.one: true
factions.claim.auto: true
factions.claim.fill: true
factions.claim.square: true
factions.claim.circle: true
factions.claim.all: true
factions.create: true factions.create: true
factions.demote: true factions.demote: true
factions.description: true factions.description: true
@ -190,17 +211,17 @@ permissions:
factions.relation: true factions.relation: true
factions.seechunk: true factions.seechunk: true
factions.seechunkold: true factions.seechunkold: true
factions.set: true
factions.set.one: true
factions.set.auto: true
factions.set.fill: true
factions.set.square: true
factions.set.circle: true
factions.set.transfer: true
factions.sethome: true factions.sethome: true
factions.name: true factions.name: true
factions.title: true factions.title: true
factions.title.color: true factions.title.color: true
factions.unclaim: true
factions.unclaim.one: true
factions.unclaim.auto: true
factions.unclaim.fill: true
factions.unclaim.square: true
factions.unclaim.circle: true
factions.unclaim.all: true
factions.unsethome: true factions.unsethome: true
factions.version: true factions.version: true
factions.kit.default: factions.kit.default: