From c058cd7ca5f327a50b66394e8b6feeb5bfff529d Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Wed, 19 Nov 2014 10:30:44 +0100 Subject: [PATCH] Split up set in to claim and unclaim --- .../java/com/massivecraft/factions/Perm.java | 21 ++++--- .../factions/cmd/CmdFactions.java | 20 +++--- .../factions/cmd/CmdFactionsClaim.java | 41 ++++++++++++ .../factions/cmd/CmdFactionsSet.java | 45 ------------- ...etTransfer.java => CmdFactionsSetAll.java} | 28 ++++++--- .../factions/cmd/CmdFactionsSetAuto.java | 32 ++++++++-- .../factions/cmd/CmdFactionsSetCircle.java | 8 ++- .../factions/cmd/CmdFactionsSetFill.java | 8 ++- .../factions/cmd/CmdFactionsSetOne.java | 8 ++- .../factions/cmd/CmdFactionsSetSquare.java | 8 ++- .../factions/cmd/CmdFactionsSetX.java | 29 ++++++++- ...XTransfer.java => CmdFactionsSetXAll.java} | 25 ++++---- .../factions/cmd/CmdFactionsSetXRadius.java | 21 +++---- .../factions/cmd/CmdFactionsSetXSimple.java | 21 +++---- .../factions/cmd/CmdFactionsUnclaim.java | 41 ++++++++++++ src/main/resources/plugin.yml | 63 ++++++++++++------- 16 files changed, 273 insertions(+), 146 deletions(-) create mode 100644 src/main/java/com/massivecraft/factions/cmd/CmdFactionsClaim.java delete mode 100644 src/main/java/com/massivecraft/factions/cmd/CmdFactionsSet.java rename src/main/java/com/massivecraft/factions/cmd/{CmdFactionsSetTransfer.java => CmdFactionsSetAll.java} (67%) rename src/main/java/com/massivecraft/factions/cmd/{CmdFactionsSetXTransfer.java => CmdFactionsSetXAll.java} (59%) create mode 100644 src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java diff --git a/src/main/java/com/massivecraft/factions/Perm.java b/src/main/java/com/massivecraft/factions/Perm.java index c427ba30..55403d8c 100644 --- a/src/main/java/com/massivecraft/factions/Perm.java +++ b/src/main/java/com/massivecraft/factions/Perm.java @@ -15,6 +15,13 @@ public enum Perm ACCESS_PLAYER("access.player"), ACCESS_FACTION("access.faction"), 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"), DEMOTE("demote"), DESCRIPTION("description"), @@ -52,17 +59,17 @@ public enum Perm RELATION("relation"), SEECHUNK("seechunk"), 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"), NAME("name"), TITLE("title"), 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"), VERSION("version"), diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactions.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactions.java index 5dc0644d..25a54989 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactions.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactions.java @@ -25,7 +25,6 @@ public class CmdFactions extends FactionsCommand public CmdFactionsName cmdFactionsName = new CmdFactionsName(); public CmdFactionsDescription cmdFactionsDescription = new CmdFactionsDescription(); public CmdFactionsMotd cmdFactionsMotd = new CmdFactionsMotd(); - public CmdFactionsSet cmdFactionsSet = new CmdFactionsSet(); public CmdFactionsSethome cmdFactionsSethome = new CmdFactionsSethome(); public CmdFactionsUnsethome cmdFactionsUnsethome = new CmdFactionsUnsethome(); public CmdFactionsInvite cmdFactionsInvite = new CmdFactionsInvite(); @@ -36,9 +35,10 @@ public class CmdFactions extends FactionsCommand public CmdFactionsOfficer cmdFactionsOfficer = new CmdFactionsOfficer(); public CmdFactionsLeader cmdFactionsLeader = new CmdFactionsLeader(); public CmdFactionsMoney cmdFactionsMoney = new CmdFactionsMoney(); - public CmdFactionsXPlaceholder cmdFactionsTax = new CmdFactionsXPlaceholder("FactionsTax", "tax"); public CmdFactionsSeeChunk cmdFactionsSeeChunk = new CmdFactionsSeeChunk(); public CmdFactionsSeeChunkOld cmdFactionsSeeChunkOld = new CmdFactionsSeeChunkOld(); + public CmdFactionsClaim cmdFactionsClaim = new CmdFactionsClaim(); + public CmdFactionsUnclaim cmdFactionsUnclaim = new CmdFactionsUnclaim(); public CmdFactionsAccess cmdFactionsAccess = new CmdFactionsAccess(); public CmdFactionsRelationAlly cmdFactionsRelationAlly = new CmdFactionsRelationAlly(); public CmdFactionsRelationTruce cmdFactionsRelationTruce = new CmdFactionsRelationTruce(); @@ -46,10 +46,11 @@ public class CmdFactions extends FactionsCommand public CmdFactionsRelationEnemy cmdFactionsRelationEnemy = new CmdFactionsRelationEnemy(); public CmdFactionsPerm cmdFactionsPerm = new CmdFactionsPerm(); public CmdFactionsFlag cmdFactionsFlag = new CmdFactionsFlag(); - public CmdFactionsDisband cmdFactionsDisband = new CmdFactionsDisband(); public CmdFactionsExpansions cmdFactionsExpansions = new CmdFactionsExpansions(); + public CmdFactionsXPlaceholder cmdFactionsTax = new CmdFactionsXPlaceholder("FactionsTax", "tax"); public CmdFactionsXPlaceholder cmdFactionsDynmap = new CmdFactionsXPlaceholder("FactionsDynmap", "dynmap"); public CmdFactionsAdmin cmdFactionsAdmin = new CmdFactionsAdmin(); + public CmdFactionsDisband cmdFactionsDisband = new CmdFactionsDisband(); public CmdFactionsPowerBoost cmdFactionsPowerBoost = new CmdFactionsPowerBoost(); 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.cmdFactionsDescription); this.addSubCommand(this.cmdFactionsMotd); - this.addSubCommand(this.cmdFactionsSet); this.addSubCommand(this.cmdFactionsSethome); this.addSubCommand(this.cmdFactionsUnsethome); this.addSubCommand(this.cmdFactionsInvite); @@ -83,9 +83,10 @@ public class CmdFactions extends FactionsCommand this.addSubCommand(this.cmdFactionsOfficer); this.addSubCommand(this.cmdFactionsLeader); this.addSubCommand(this.cmdFactionsMoney); - this.addSubCommand(this.cmdFactionsTax); this.addSubCommand(this.cmdFactionsSeeChunk); this.addSubCommand(this.cmdFactionsSeeChunkOld); + this.addSubCommand(this.cmdFactionsClaim); + this.addSubCommand(this.cmdFactionsUnclaim); this.addSubCommand(this.cmdFactionsAccess); this.addSubCommand(this.cmdFactionsRelationAlly); this.addSubCommand(this.cmdFactionsRelationTruce); @@ -93,18 +94,17 @@ public class CmdFactions extends FactionsCommand this.addSubCommand(this.cmdFactionsRelationEnemy); this.addSubCommand(this.cmdFactionsPerm); this.addSubCommand(this.cmdFactionsFlag); - this.addSubCommand(this.cmdFactionsDisband); this.addSubCommand(this.cmdFactionsExpansions); + this.addSubCommand(this.cmdFactionsTax); this.addSubCommand(this.cmdFactionsDynmap); this.addSubCommand(this.cmdFactionsAdmin); + this.addSubCommand(this.cmdFactionsDisband); this.addSubCommand(this.cmdFactionsPowerBoost); this.addSubCommand(this.cmdFactionsVersion); // Deprecated Commands - this.addSubCommand(new CmdFactionsXDeprecated(this.cmdFactionsSet, "claim")); - this.addSubCommand(new CmdFactionsXDeprecated(this.cmdFactionsSet, "unclaim")); - this.addSubCommand(new CmdFactionsXDeprecated(this.cmdFactionsSet, "autoclaim")); - this.addSubCommand(new CmdFactionsXDeprecated(this.cmdFactionsSet, "unclaimall")); + this.addSubCommand(new CmdFactionsXDeprecated(this.cmdFactionsClaim.cmdFactionsClaimAuto, "autoclaim")); + this.addSubCommand(new CmdFactionsXDeprecated(this.cmdFactionsUnclaim.cmdFactionsUnclaimAll, "unclaimall")); this.addSubCommand(new CmdFactionsXDeprecated(this.cmdFactionsFlag, "open")); this.addSubCommand(new CmdFactionsXDeprecated(this.cmdFactionsFaction, "show", "who")); } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsClaim.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsClaim.java new file mode 100644 index 00000000..1154dad6 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsClaim.java @@ -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)); + } + +} diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSet.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSet.java deleted file mode 100644 index 2133ea5c..00000000 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSet.java +++ /dev/null @@ -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 none to unclaim."); - - // Requirements - this.addRequirements(ReqHasPerm.get(Perm.SET.node)); - } - - - -} diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetTransfer.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetAll.java similarity index 67% rename from src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetTransfer.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetAll.java index bc596e65..22dbf62b 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetTransfer.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetAll.java @@ -8,24 +8,30 @@ 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; +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; -public class CmdFactionsSetTransfer extends CmdFactionsSetXTransfer +public class CmdFactionsSetAll extends CmdFactionsSetXAll { // -------------------------------------------- // // CONSTRUCT // -------------------------------------------- // - public CmdFactionsSetTransfer() + public CmdFactionsSetAll(boolean claim) { + // Super + super(claim); + // Aliases - this.addAliases("t", "transfer"); - + this.addAliases("all"); + // 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 public Set getChunks() { + // World + String word = (this.isClaim() ? "claim" : "unclaim"); + // Create Ret Set chunks = null; @@ -45,8 +54,8 @@ public class CmdFactionsSetTransfer extends CmdFactionsSetXTransfer if (MUtil.list("a", "al", "all").contains(this.arg(0).toLowerCase())) { chunks = BoardColl.get().getChunks(oldFaction); - this.setFormatOne("%s %s %d chunk using transfer all."); - this.setFormatMany("%s %s %d chunks using transfer all."); + this.setFormatOne("%s %s %d chunk using " + word + " all."); + this.setFormatMany("%s %s %d chunks using " + word + " all."); } else { @@ -71,9 +80,8 @@ public class CmdFactionsSetTransfer extends CmdFactionsSetXTransfer Board board = BoardColl.get().get(worldId); chunks = board.getChunks(oldFaction); String worldDisplayName = Mixin.getWorldDisplayName(worldId); - this.setFormatOne("%s %s %d chunk using transfer " + worldDisplayName + "."); - this.setFormatMany("%s %s %d chunks using transfer " + worldDisplayName + "."); - + this.setFormatOne("%s %s %d chunk using " + word + " " + worldDisplayName + "."); + this.setFormatMany("%s %s %d chunks using " + word + " " + worldDisplayName + "."); } // Return Ret diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetAuto.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetAuto.java index 83b2c784..437a922d 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetAuto.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetAuto.java @@ -6,6 +6,7 @@ import java.util.Set; import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.entity.Faction; +import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.factions.entity.MPerm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; @@ -14,21 +15,36 @@ import com.massivecraft.massivecore.ps.PS; 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 // -------------------------------------------- // - public CmdFactionsSetAuto() + public CmdFactionsSetAuto(boolean claim) { + // Fields + this.setClaim(claim); + // Aliases this.addAliases("a", "auto"); // Args - this.addOptionalArg("faction", "you"); + if (claim) + { + this.addOptionalArg("faction", "you"); + } // Requirements 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() { // 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? if (newFaction == null || newFaction == msender.getAutoClaimFaction()) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetCircle.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetCircle.java index 5a9f4efa..cd7507c6 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetCircle.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetCircle.java @@ -15,8 +15,11 @@ public class CmdFactionsSetCircle extends CmdFactionsSetXRadius // CONSTRUCT // -------------------------------------------- // - public CmdFactionsSetCircle() + public CmdFactionsSetCircle(boolean claim) { + // Super + super(claim); + // Aliases this.addAliases("c", "circle"); @@ -26,7 +29,8 @@ public class CmdFactionsSetCircle extends CmdFactionsSetXRadius // Requirements 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)); } // -------------------------------------------- // diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetFill.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetFill.java index c64f4c3c..e1be83b3 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetFill.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetFill.java @@ -19,8 +19,11 @@ public class CmdFactionsSetFill extends CmdFactionsSetXSimple // CONSTRUCT // -------------------------------------------- // - public CmdFactionsSetFill() + public CmdFactionsSetFill(boolean claim) { + // Super + super(claim); + // Aliases this.addAliases("f", "fill"); @@ -30,7 +33,8 @@ public class CmdFactionsSetFill extends CmdFactionsSetXSimple // Requirements 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)); } // -------------------------------------------- // diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetOne.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetOne.java index d7cd87c3..d722d0ac 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetOne.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetOne.java @@ -15,14 +15,18 @@ public class CmdFactionsSetOne extends CmdFactionsSetXSimple // CONSTRUCT // -------------------------------------------- // - public CmdFactionsSetOne() + public CmdFactionsSetOne(boolean claim) { + // Super + super(claim); + // Aliases this.addAliases("o", "one"); // Requirements 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)); } // -------------------------------------------- // diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetSquare.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetSquare.java index 8793aad5..d1852429 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetSquare.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetSquare.java @@ -15,8 +15,11 @@ public class CmdFactionsSetSquare extends CmdFactionsSetXRadius // CONSTRUCT // -------------------------------------------- // - public CmdFactionsSetSquare() + public CmdFactionsSetSquare(boolean claim) { + // Super + super(claim); + // Aliases this.addAliases("s", "square"); @@ -26,7 +29,8 @@ public class CmdFactionsSetSquare extends CmdFactionsSetXRadius // Requirements 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)); } // -------------------------------------------- // diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetX.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetX.java index 4d03d77f..91886e22 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetX.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetX.java @@ -4,6 +4,7 @@ import java.util.Set; import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.entity.Faction; +import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.massivecore.ps.PS; @@ -21,6 +22,23 @@ public abstract class CmdFactionsSetX extends FactionsCommand public String getFormatMany() { return this.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 // -------------------------------------------- // @@ -43,8 +61,6 @@ public abstract class CmdFactionsSetX extends FactionsCommand // ABSTRACT // -------------------------------------------- // - public abstract int getFactionArgIndex(); - public abstract Set getChunks(); // -------------------------------------------- // @@ -53,7 +69,14 @@ public abstract class CmdFactionsSetX extends FactionsCommand public Faction getNewFaction() { - return this.arg(this.getFactionArgIndex(), ARFaction.get(), msenderFaction); + if (this.isClaim()) + { + return this.arg(this.getFactionArgIndex(), ARFaction.get(), msenderFaction); + } + else + { + return FactionColl.get().getNone(); + } } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetXTransfer.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetXAll.java similarity index 59% rename from src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetXTransfer.java rename to src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetXAll.java index fb791ad7..4b0fedf5 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetXTransfer.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetXAll.java @@ -3,28 +3,25 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.entity.Faction; -public abstract class CmdFactionsSetXTransfer extends CmdFactionsSetX +public abstract class CmdFactionsSetXAll extends CmdFactionsSetX { // -------------------------------------------- // // CONSTRUCT // -------------------------------------------- // - public CmdFactionsSetXTransfer() + public CmdFactionsSetXAll(boolean claim) { + // Super + super(claim); + // Args this.addRequiredArg("all|map"); - this.addRequiredArg("old"); - this.addRequiredArg("new"); - } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public int getFactionArgIndex() - { - return 2; + this.addRequiredArg("faction"); + if (claim) + { + this.addRequiredArg("newfaction"); + this.setFactionArgIndex(2); + } } // -------------------------------------------- // diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetXRadius.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetXRadius.java index 2b668792..836f1a49 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetXRadius.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetXRadius.java @@ -10,21 +10,18 @@ public abstract class CmdFactionsSetXRadius extends CmdFactionsSetX // CONSTRUCT // -------------------------------------------- // - public CmdFactionsSetXRadius() + public CmdFactionsSetXRadius(boolean claim) { + // Super + super(claim); + // Args this.addOptionalArg("radius", "1"); - this.addOptionalArg("faction", "you"); - } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public int getFactionArgIndex() - { - return 1; + if (claim) + { + this.addOptionalArg("faction", "you"); + this.setFactionArgIndex(1); + } } // -------------------------------------------- // diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetXSimple.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetXSimple.java index 590bebd0..6c0c7544 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetXSimple.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetXSimple.java @@ -6,20 +6,17 @@ public abstract class CmdFactionsSetXSimple extends CmdFactionsSetX // CONSTRUCT // -------------------------------------------- // - public CmdFactionsSetXSimple() + public CmdFactionsSetXSimple(boolean claim) { + // Super + super(claim); + // Args - this.addOptionalArg("faction", "you"); - } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public int getFactionArgIndex() - { - return 0; + if (claim) + { + this.addOptionalArg("faction", "you"); + this.setFactionArgIndex(0); + } } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java new file mode 100644 index 00000000..07234147 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java @@ -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)); + } + +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 3c7a1eff..385f98f6 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -15,6 +15,13 @@ permissions: factions.access.player: {description: grant player access, with the proper fperm, default: false} factions.access.view: {description: view access, 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.demote: {description: demote lesser members in your faction, 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.seechunk: {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.name: {description: set faction name, default: false} factions.title: {description: set player title, 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.version: {description: see plugin version, default: false} # -------------------------------------------- # @@ -75,6 +82,13 @@ permissions: factions.access.player: true factions.access.view: 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.demote: true factions.description: true @@ -112,17 +126,17 @@ permissions: factions.relation: true factions.seechunk: 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.name: true factions.title: 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.version: true # -------------------------------------------- # @@ -158,6 +172,13 @@ permissions: factions.access.faction: true factions.access.player: 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.demote: true factions.description: true @@ -190,17 +211,17 @@ permissions: factions.relation: true factions.seechunk: 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.name: true factions.title: 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.version: true factions.kit.default: