Page ArgSetting

This commit is contained in:
Olof Larsson 2015-05-13 23:00:53 +02:00
parent ab9ea25bfd
commit 24344ab6c8
7 changed files with 27 additions and 26 deletions

View File

@ -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<String> messages = new ArrayList<String>();
@ -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));
}
}

View File

@ -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<MPlayer> pager = new PagerSimple<MPlayer>(mplayers, sender);
// Use Pager
List<String> messages = pager.getPageTxt(pageHumanBased, "Invited Players List", new Stringifier<MPlayer>(){
List<String> messages = pager.getPageTxt(page, "Invited Players List", new Stringifier<MPlayer>(){
public String toString(MPlayer target, int index)
{

View File

@ -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<Faction> pager = new PagerSimple<Faction>(factions, sender);
// Use Pager
List<String> messages = pager.getPageTxt(pageHumanBased, "Faction List", new Stringifier<Faction>() {
List<String> messages = pager.getPageTxt(page, "Faction List", new Stringifier<Faction>() {
@Override
public String toString(Faction faction, int index)
{

View File

@ -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<String> messages = new ArrayList<String>();
@ -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));
}
}

View File

@ -18,7 +18,8 @@ public class CmdFactionsPowerBoost extends FactionsCommand
// FIELDS
// -------------------------------------------- //
private ArgSetting setting = ArgSetting.of(ARMPlayer.getAny(), false, "name", null);
private ArgSetting<MPlayer> settingMplayer = new ArgSetting<MPlayer>(ARMPlayer.getAny(), "name");
private ArgSetting<Faction> settingFaction = new ArgSetting<Faction>(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);

View File

@ -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)

View File

@ -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<MPlayer> sortedBy = this.readArg(PlayerInactivityComparator.get());
@ -66,7 +66,7 @@ public class CmdFactionsStatus extends FactionsCommand
String pagerTitle = Txt.parse("<i>Status of %s<i>.", faction.describeTo(msender, true));
// Use Pager
List<String> messages = pager.getPageTxt(pageHumanBased, pagerTitle, new Stringifier<MPlayer>(){
List<String> messages = pager.getPageTxt(page, pagerTitle, new Stringifier<MPlayer>(){
@Override
public String toString(MPlayer mplayer, int index)