From cfda6796e45f1548f8f13c3722ed79686fb71db6 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Tue, 8 Sep 2015 09:11:30 +0200 Subject: [PATCH] More Pager Use --- .../CmdMassiveCoreUsysAspectList.java | 26 +++++++++---------- .../CmdMassiveCoreUsysMultiverseList.java | 25 +++++++++--------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspectList.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspectList.java index e1e9bc87..3c3b7c0a 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspectList.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysAspectList.java @@ -1,8 +1,5 @@ package com.massivecraft.massivecore.cmd.massivecore; -import java.util.ArrayList; -import java.util.List; - import com.massivecraft.massivecore.Aspect; import com.massivecraft.massivecore.AspectColl; import com.massivecraft.massivecore.MassiveCorePerm; @@ -10,6 +7,8 @@ import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.cmd.ArgSetting; import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.pager.Pager; +import com.massivecraft.massivecore.pager.Stringifier; import com.massivecraft.massivecore.util.Txt; public class CmdMassiveCoreUsysAspectList extends MassiveCommand @@ -40,17 +39,18 @@ public class CmdMassiveCoreUsysAspectList extends MassiveCommand // Args int page = this.readArg(); - // Create Lines - List lines = new ArrayList(); - - for (Aspect aspect : AspectColl.get().getAllRegistered()) + // Pager Create + Pager pager = new Pager(this, "Aspect List", page, AspectColl.get().getAllRegistered(), new Stringifier() { - String line = Txt.parse(""+aspect.getId()+" --> "+aspect.getMultiverse().getId()); - lines.add(line); - } - - // Send them - this.message(Txt.getPage(lines, page, "Aspect List", this)); + @Override + public String toString(Aspect aspect, int index) + { + return Txt.parse(""+aspect.getId()+" --> "+aspect.getMultiverse().getId()); + } + }); + + // Pager Message + pager.message(); } } diff --git a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseList.java b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseList.java index 3196c029..a733ef3e 100644 --- a/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseList.java +++ b/src/com/massivecraft/massivecore/cmd/massivecore/CmdMassiveCoreUsysMultiverseList.java @@ -1,8 +1,5 @@ package com.massivecraft.massivecore.cmd.massivecore; -import java.util.ArrayList; -import java.util.List; - import com.massivecraft.massivecore.MassiveCorePerm; import com.massivecraft.massivecore.MassiveException; import com.massivecraft.massivecore.Multiverse; @@ -10,6 +7,8 @@ import com.massivecraft.massivecore.MultiverseColl; import com.massivecraft.massivecore.cmd.ArgSetting; import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.pager.Pager; +import com.massivecraft.massivecore.pager.Stringifier; import com.massivecraft.massivecore.util.Txt; public class CmdMassiveCoreUsysMultiverseList extends MassiveCommand @@ -40,16 +39,18 @@ public class CmdMassiveCoreUsysMultiverseList extends MassiveCommand // Args int page = this.readArg(); - // Create Lines - List lines = new ArrayList(); - for (Multiverse multiverse : MultiverseColl.get().getAll()) + // Pager Create + Pager pager = new Pager(this, "Multiverse List", page, MultiverseColl.get().getAll(), new Stringifier() { - String line = Txt.parse(""+multiverse.getId()+" has "+Txt.implodeCommaAndDot(multiverse.getUniverses(), "%s", ", ", " and ", ".")); - lines.add(line); - } - - // Send them - this.message(Txt.getPage(lines, page, "Multiverse List", this)); + @Override + public String toString(Multiverse multiverse, int index) + { + return Txt.parse(""+multiverse.getId()+" has "+Txt.implodeCommaAndDot(multiverse.getUniverses(), "%s", ", ", " and ", ".")); + } + }); + + // Pager Message + pager.message(); } }