From 24344ab6c8594fc970b4c0d8c7edb578130f9664 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Wed, 13 May 2015 23:00:53 +0200 Subject: [PATCH] Page ArgSetting --- .../massivecraft/factions/cmd/CmdFactionsFlagList.java | 8 ++++---- .../massivecraft/factions/cmd/CmdFactionsInviteList.java | 8 ++++---- src/com/massivecraft/factions/cmd/CmdFactionsList.java | 8 ++++---- .../massivecraft/factions/cmd/CmdFactionsPermList.java | 8 ++++---- .../massivecraft/factions/cmd/CmdFactionsPowerBoost.java | 9 +++++---- .../massivecraft/factions/cmd/CmdFactionsSetXRadius.java | 4 ++-- src/com/massivecraft/factions/cmd/CmdFactionsStatus.java | 8 ++++---- 7 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsFlagList.java b/src/com/massivecraft/factions/cmd/CmdFactionsFlagList.java index cb896a52..497c5a74 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsFlagList.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsFlagList.java @@ -6,7 +6,7 @@ import java.util.List; import com.massivecraft.factions.Perm; import com.massivecraft.factions.entity.MFlag; import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.cmd.arg.ARInteger; +import com.massivecraft.massivecore.cmd.ArgSetting; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.util.Txt; @@ -22,7 +22,7 @@ public class CmdFactionsFlagList extends FactionsCommand this.addAliases("l", "list"); // Args - this.addArg(ARInteger.get(), "page", "1"); + this.addArg(ArgSetting.getPage()); // Requirements this.addRequirements(ReqHasPerm.get(Perm.FLAG_LIST.node)); @@ -36,7 +36,7 @@ public class CmdFactionsFlagList extends FactionsCommand public void perform() throws MassiveException { // Args - int pageHumanBased = this.readArg(1); + int page = this.readArg(); //Create messages List messages = new ArrayList(); @@ -48,7 +48,7 @@ public class CmdFactionsFlagList extends FactionsCommand } //Send messages - sendMessage(Txt.getPage(messages, pageHumanBased, "Available Faction Flags", sender)); + sendMessage(Txt.getPage(messages, page, "Available Faction Flags", sender)); } } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsInviteList.java b/src/com/massivecraft/factions/cmd/CmdFactionsInviteList.java index aecaf88c..f31bf833 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsInviteList.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsInviteList.java @@ -9,7 +9,7 @@ import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MPerm; import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.cmd.arg.ARInteger; +import com.massivecraft.massivecore.cmd.ArgSetting; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.pager.PagerSimple; import com.massivecraft.massivecore.pager.Stringifier; @@ -27,7 +27,7 @@ public class CmdFactionsInviteList extends FactionsCommand this.addAliases("l", "list"); // Args - this.addArg(ARInteger.get(), "page", "1"); + this.addArg(ArgSetting.getPage()); this.addArg(ARFaction.get(), "faction", "you"); // Requirements @@ -42,7 +42,7 @@ public class CmdFactionsInviteList extends FactionsCommand public void perform() throws MassiveException { // Args - int pageHumanBased = this.readArg(1); + int page = this.readArg(); Faction faction = this.readArg(msenderFaction); @@ -56,7 +56,7 @@ public class CmdFactionsInviteList extends FactionsCommand final PagerSimple pager = new PagerSimple(mplayers, sender); // Use Pager - List messages = pager.getPageTxt(pageHumanBased, "Invited Players List", new Stringifier(){ + List messages = pager.getPageTxt(page, "Invited Players List", new Stringifier(){ public String toString(MPlayer target, int index) { diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsList.java b/src/com/massivecraft/factions/cmd/CmdFactionsList.java index e90e7eec..adb04a25 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsList.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsList.java @@ -11,7 +11,7 @@ import com.massivecraft.factions.Perm; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.cmd.arg.ARInteger; +import com.massivecraft.massivecore.cmd.ArgSetting; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.mixin.Mixin; import com.massivecraft.massivecore.pager.PagerSimple; @@ -30,7 +30,7 @@ public class CmdFactionsList extends FactionsCommand this.addAliases("l", "list"); // Args - this.addArg(ARInteger.get(), "page", "1"); + this.addArg(ArgSetting.getPage()); // Requirements this.addRequirements(ReqHasPerm.get(Perm.LIST.node)); @@ -44,7 +44,7 @@ public class CmdFactionsList extends FactionsCommand public void perform() throws MassiveException { // Args - final int pageHumanBased = this.readArg(1); + final int page = this.readArg(); // NOTE: The faction list is quite slow and mostly thread safe. // We run it asynchronously to spare the primary server thread. @@ -59,7 +59,7 @@ public class CmdFactionsList extends FactionsCommand final PagerSimple pager = new PagerSimple(factions, sender); // Use Pager - List messages = pager.getPageTxt(pageHumanBased, "Faction List", new Stringifier() { + List messages = pager.getPageTxt(page, "Faction List", new Stringifier() { @Override public String toString(Faction faction, int index) { diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsPermList.java b/src/com/massivecraft/factions/cmd/CmdFactionsPermList.java index 9d3239e5..e36a19ef 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsPermList.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsPermList.java @@ -6,7 +6,7 @@ import java.util.List; import com.massivecraft.factions.Perm; import com.massivecraft.factions.entity.MPerm; import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.cmd.arg.ARInteger; +import com.massivecraft.massivecore.cmd.ArgSetting; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.util.Txt; @@ -22,7 +22,7 @@ public class CmdFactionsPermList extends FactionsCommand this.addAliases("l", "list"); // Args - this.addArg(ARInteger.get(), "page", "1"); + this.addArg(ArgSetting.getPage()); // Requirements this.addRequirements(ReqHasPerm.get(Perm.PERM_LIST.node)); @@ -36,7 +36,7 @@ public class CmdFactionsPermList extends FactionsCommand public void perform() throws MassiveException { // Args - int pageHumanBased = this.readArg(1); + int page = this.readArg(); // Create messages List messages = new ArrayList(); @@ -48,7 +48,7 @@ public class CmdFactionsPermList extends FactionsCommand } // Send messages - sendMessage(Txt.getPage(messages, pageHumanBased, "Available Faction Perms", sender)); + sendMessage(Txt.getPage(messages, page, "Available Faction Perms", sender)); } } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsPowerBoost.java b/src/com/massivecraft/factions/cmd/CmdFactionsPowerBoost.java index e9b390aa..4e8d5940 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsPowerBoost.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsPowerBoost.java @@ -18,7 +18,8 @@ public class CmdFactionsPowerBoost extends FactionsCommand // FIELDS // -------------------------------------------- // - private ArgSetting setting = ArgSetting.of(ARMPlayer.getAny(), false, "name", null); + private ArgSetting settingMplayer = new ArgSetting(ARMPlayer.getAny(), "name"); + private ArgSetting settingFaction = new ArgSetting(ARFaction.get(), "name"); // -------------------------------------------- // // CONSTRUCT @@ -31,7 +32,7 @@ public class CmdFactionsPowerBoost extends FactionsCommand // Args this.addArg(ARString.get(), "p|f|player|faction"); - this.addArg(setting); + this.addArg(settingMplayer); this.addArg(ARDouble.get(), "#"); // Requirements @@ -64,7 +65,7 @@ public class CmdFactionsPowerBoost extends FactionsCommand if (doPlayer) { - setting.setReader(ARMPlayer.getAny()); + this.getArgSettings().set(1, settingMplayer); MPlayer targetPlayer = this.readArgAt(1); targetPlayer.setPowerBoost(targetPower); @@ -72,7 +73,7 @@ public class CmdFactionsPowerBoost extends FactionsCommand } else { - setting.setReader(ARFaction.get()); + this.getArgSettings().set(1, settingFaction); Faction targetFaction = this.readArgAt(1); targetFaction.setPowerBoost(targetPower); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSetXRadius.java b/src/com/massivecraft/factions/cmd/CmdFactionsSetXRadius.java index 73372020..3d0fe31c 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSetXRadius.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsSetXRadius.java @@ -18,7 +18,7 @@ public abstract class CmdFactionsSetXRadius extends CmdFactionsSetX super(claim); // Args - this.addArg(ARInteger.get(), "radius", "1"); + this.addArg(1, ARInteger.get(), "radius"); if (claim) { this.addArg(ARFaction.get(), "faction", "you"); @@ -32,7 +32,7 @@ public abstract class CmdFactionsSetXRadius extends CmdFactionsSetX public Integer getRadius() throws MassiveException { - int radius = this.readArg(1); + int radius = this.readArg(); // Radius Claim Min if (radius < 1) diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsStatus.java b/src/com/massivecraft/factions/cmd/CmdFactionsStatus.java index 6a81365a..2fc5e1d3 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsStatus.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsStatus.java @@ -13,7 +13,7 @@ import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MPerm; import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.massivecore.MassiveException; -import com.massivecraft.massivecore.cmd.arg.ARInteger; +import com.massivecraft.massivecore.cmd.ArgSetting; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.pager.PagerSimple; import com.massivecraft.massivecore.pager.Stringifier; @@ -34,7 +34,7 @@ public class CmdFactionsStatus extends FactionsCommand this.addAliases("s", "status"); // Args - this.addArg(ARInteger.get(), "page", "1"); + this.addArg(ArgSetting.getPage()); this.addArg(ARFaction.get(), "faction", "you"); this.addArg(ARSortMPlayer.get(), "sort by", "time"); @@ -50,7 +50,7 @@ public class CmdFactionsStatus extends FactionsCommand public void perform() throws MassiveException { // Args - Integer pageHumanBased = this.readArg(1); + int page = this.readArg(); Faction faction = this.readArg(msenderFaction); Comparator sortedBy = this.readArg(PlayerInactivityComparator.get()); @@ -66,7 +66,7 @@ public class CmdFactionsStatus extends FactionsCommand String pagerTitle = Txt.parse("Status of %s.", faction.describeTo(msender, true)); // Use Pager - List messages = pager.getPageTxt(pageHumanBased, pagerTitle, new Stringifier(){ + List messages = pager.getPageTxt(page, pagerTitle, new Stringifier(){ @Override public String toString(MPlayer mplayer, int index)