From e3785a179095d51e224a1b4e35b6f77bd80c9886 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Tue, 14 Oct 2014 08:56:07 +0200 Subject: [PATCH] Customized formats when using different claim tools. --- .../factions/cmd/CmdFactionsSetCircle.java | 4 ++++ .../factions/cmd/CmdFactionsSetFill.java | 4 ++++ .../factions/cmd/CmdFactionsSetSquare.java | 4 ++++ .../factions/cmd/CmdFactionsSetTransfer.java | 6 ++++++ .../massivecraft/factions/cmd/CmdFactionsSetX.java | 14 +++++++++++++- .../com/massivecraft/factions/entity/MPlayer.java | 9 ++++++++- 6 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetCircle.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetCircle.java index 30f11019..680fee37 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetCircle.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetCircle.java @@ -20,6 +20,10 @@ public class CmdFactionsSetCircle extends CmdFactionsSetXRadius // Aliases this.addAliases("c", "circle"); + // Format + this.setFormatOne(null); + this.setFormatMany("%s %s %d chunks using circle near %s."); + // Requirements this.addRequirements(ReqIsPlayer.get()); this.addRequirements(ReqHasPerm.get(Perm.SET_CIRCLE.node)); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetFill.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetFill.java index 24a84350..b179005f 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetFill.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetFill.java @@ -24,6 +24,10 @@ public class CmdFactionsSetFill extends CmdFactionsSetXSimple // Aliases this.addAliases("f", "fill"); + // Format + this.setFormatOne(null); + this.setFormatMany("%s %s %d chunks using fill near %s."); + // Requirements this.addRequirements(ReqIsPlayer.get()); this.addRequirements(ReqHasPerm.get(Perm.SET_FILL.node)); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetSquare.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetSquare.java index d40d440b..1c4330b9 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetSquare.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetSquare.java @@ -20,6 +20,10 @@ public class CmdFactionsSetSquare extends CmdFactionsSetXRadius // Aliases this.addAliases("s", "square"); + // Format + this.setFormatOne(null); + this.setFormatMany("%s %s %d chunks using square near %s."); + // Requirements this.addRequirements(ReqIsPlayer.get()); this.addRequirements(ReqHasPerm.get(Perm.SET_SQUARE.node)); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetTransfer.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetTransfer.java index 9581f45d..5a7ff7a4 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetTransfer.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetTransfer.java @@ -8,6 +8,7 @@ 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.mixin.Mixin; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.util.MUtil; @@ -44,6 +45,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 all %d chunks."); + this.setFormatMany("%s %s all %d chunks."); } else { @@ -67,6 +70,9 @@ public class CmdFactionsSetTransfer extends CmdFactionsSetXTransfer } Board board = BoardColl.get().get(worldId); chunks = board.getChunks(oldFaction); + String worldDisplayName = Mixin.getWorldDisplayName(worldId); + this.setFormatOne("%s %s all %d chunks in " + worldDisplayName + "."); + this.setFormatMany("%s %s all %d chunks in " + worldDisplayName + "."); } // Return Ret diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetX.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetX.java index b23a3d7a..4d03d77f 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetX.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSetX.java @@ -9,6 +9,18 @@ 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; } + // -------------------------------------------- // // OVERRIDE // -------------------------------------------- // @@ -24,7 +36,7 @@ public abstract class CmdFactionsSetX extends FactionsCommand if (chunks == null) return; // Apply / Inform - msender.tryClaim(newFaction, chunks); + msender.tryClaim(newFaction, chunks, this.getFormatOne(), this.getFormatMany()); } // -------------------------------------------- // diff --git a/src/main/java/com/massivecraft/factions/entity/MPlayer.java b/src/main/java/com/massivecraft/factions/entity/MPlayer.java index 3de6844e..355fc560 100644 --- a/src/main/java/com/massivecraft/factions/entity/MPlayer.java +++ b/src/main/java/com/massivecraft/factions/entity/MPlayer.java @@ -799,8 +799,15 @@ public class MPlayer extends SenderEntity implements EconomyParticipato // NEW public boolean tryClaim(Faction newFaction, Collection pss) + { + return this.tryClaim(newFaction, pss, null, null); + } + public boolean tryClaim(Faction newFaction, Collection pss, String formatOne, String formatMany) { // Args + if (formatOne == null) formatOne = "%s %s %d chunk %s."; + if (formatMany == null) formatMany = "%s %s %d chunks near %s."; + if (newFaction == null) throw new NullPointerException("newFaction"); if (pss == null) throw new NullPointerException("pss"); @@ -849,7 +856,7 @@ public class MPlayer extends SenderEntity implements EconomyParticipato for (MPlayer informee : informees) { - informee.msg("%s %s %d " + (oldChunks.size() == 1 ? "chunk" : "chunks") + " near %s", this.describeTo(informee, true), typeString, oldChunks.size(), chunkString); + informee.msg((oldChunks.size() == 1 ? formatOne : formatMany), this.describeTo(informee, true), typeString, oldChunks.size(), chunkString); informee.msg(" %s --> %s", oldFaction.describeTo(informee, true), newFaction.describeTo(informee, true)); } }