MassiveCore - Pager Improvement
This commit is contained in:
parent
841a2da73d
commit
658905c4e8
@ -48,7 +48,7 @@ public class CmdFactionsFlagList extends FactionsCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Send messages
|
//Send messages
|
||||||
message(Txt.getPage(messages, page, "Available Faction Flags", sender));
|
message(Txt.getPage(messages, page, "Available Faction Flags", this));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,8 @@ import com.massivecraft.factions.entity.MPlayer;
|
|||||||
import com.massivecraft.massivecore.MassiveException;
|
import com.massivecraft.massivecore.MassiveException;
|
||||||
import com.massivecraft.massivecore.cmd.ArgSetting;
|
import com.massivecraft.massivecore.cmd.ArgSetting;
|
||||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||||
import com.massivecraft.massivecore.pager.PagerSimple;
|
import com.massivecraft.massivecore.mson.Mson;
|
||||||
|
import com.massivecraft.massivecore.pager.Pager;
|
||||||
import com.massivecraft.massivecore.pager.Stringifier;
|
import com.massivecraft.massivecore.pager.Stringifier;
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
import com.massivecraft.massivecore.util.Txt;
|
||||||
|
|
||||||
@ -51,13 +52,9 @@ public class CmdFactionsInviteList extends FactionsCommand
|
|||||||
// MPerm
|
// MPerm
|
||||||
if ( ! MPerm.getPermInvite().has(msender, msenderFaction, true)) return;
|
if ( ! MPerm.getPermInvite().has(msender, msenderFaction, true)) return;
|
||||||
|
|
||||||
// Create Pager
|
// Pager Create
|
||||||
final List<MPlayer> mplayers = faction.getInvitedMPlayers();
|
final List<MPlayer> mplayers = faction.getInvitedMPlayers();
|
||||||
final PagerSimple<MPlayer> pager = new PagerSimple<MPlayer>(mplayers, sender);
|
final Pager<MPlayer> pager = new Pager<MPlayer>(this, "Invited Players List", page, mplayers, new Stringifier<MPlayer>(){
|
||||||
|
|
||||||
// Use Pager
|
|
||||||
List<String> messages = pager.getPageTxt(page, "Invited Players List", new Stringifier<MPlayer>(){
|
|
||||||
|
|
||||||
public String toString(MPlayer target, int index)
|
public String toString(MPlayer target, int index)
|
||||||
{
|
{
|
||||||
// TODO: Madus would like to implement this in MPlayer
|
// TODO: Madus would like to implement this in MPlayer
|
||||||
@ -77,8 +74,8 @@ public class CmdFactionsInviteList extends FactionsCommand
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Send message
|
// Pager Message
|
||||||
message(messages);
|
pager.message();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package com.massivecraft.factions.cmd;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
import com.massivecraft.factions.FactionListComparator;
|
import com.massivecraft.factions.FactionListComparator;
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
@ -14,7 +13,8 @@ import com.massivecraft.massivecore.MassiveException;
|
|||||||
import com.massivecraft.massivecore.cmd.ArgSetting;
|
import com.massivecraft.massivecore.cmd.ArgSetting;
|
||||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||||
import com.massivecraft.massivecore.mixin.Mixin;
|
import com.massivecraft.massivecore.mixin.Mixin;
|
||||||
import com.massivecraft.massivecore.pager.PagerSimple;
|
import com.massivecraft.massivecore.mson.Mson;
|
||||||
|
import com.massivecraft.massivecore.pager.Pager;
|
||||||
import com.massivecraft.massivecore.pager.Stringifier;
|
import com.massivecraft.massivecore.pager.Stringifier;
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
import com.massivecraft.massivecore.util.Txt;
|
||||||
|
|
||||||
@ -44,22 +44,13 @@ public class CmdFactionsList extends FactionsCommand
|
|||||||
public void perform() throws MassiveException
|
public void perform() throws MassiveException
|
||||||
{
|
{
|
||||||
// Args
|
// Args
|
||||||
final int page = this.readArg();
|
int page = this.readArg();
|
||||||
|
|
||||||
// NOTE: The faction list is quite slow and mostly thread safe.
|
// NOTE: The faction list is quite slow and mostly thread safe.
|
||||||
// We run it asynchronously to spare the primary server thread.
|
// We run it asynchronously to spare the primary server thread.
|
||||||
final CommandSender sender = this.sender;
|
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
// Create Pager
|
|
||||||
final List<Faction> factions = FactionColl.get().getAll(FactionListComparator.get());
|
|
||||||
final PagerSimple<Faction> pager = new PagerSimple<Faction>(factions, sender);
|
|
||||||
|
|
||||||
// Use Pager
|
// Pager Create
|
||||||
List<String> messages = pager.getPageTxt(page, "Faction List", new Stringifier<Faction>() {
|
final Pager<Faction> pager = new Pager<Faction>(this, "Faction List", page, new Stringifier<Faction>() {
|
||||||
@Override
|
@Override
|
||||||
public String toString(Faction faction, int index)
|
public String toString(Faction faction, int index)
|
||||||
{
|
{
|
||||||
@ -81,8 +72,17 @@ public class CmdFactionsList extends FactionsCommand
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Send Messages
|
Bukkit.getScheduler().runTaskAsynchronously(Factions.get(), new Runnable()
|
||||||
Mixin.messageOne(sender, messages);
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
// Pager Items
|
||||||
|
final List<Faction> factions = FactionColl.get().getAll(FactionListComparator.get());
|
||||||
|
pager.setItems(factions);
|
||||||
|
|
||||||
|
// Pager Message
|
||||||
|
pager.message();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ public class CmdFactionsPermList extends FactionsCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Send messages
|
// Send messages
|
||||||
message(Txt.getPage(messages, page, "Available Faction Perms", sender));
|
message(Txt.getPage(messages, page, "Available Faction Perms", this));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,8 @@ import com.massivecraft.factions.entity.MPlayer;
|
|||||||
import com.massivecraft.massivecore.MassiveException;
|
import com.massivecraft.massivecore.MassiveException;
|
||||||
import com.massivecraft.massivecore.cmd.ArgSetting;
|
import com.massivecraft.massivecore.cmd.ArgSetting;
|
||||||
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
import com.massivecraft.massivecore.cmd.req.ReqHasPerm;
|
||||||
import com.massivecraft.massivecore.pager.PagerSimple;
|
import com.massivecraft.massivecore.mson.Mson;
|
||||||
|
import com.massivecraft.massivecore.pager.Pager;
|
||||||
import com.massivecraft.massivecore.pager.Stringifier;
|
import com.massivecraft.massivecore.pager.Stringifier;
|
||||||
import com.massivecraft.massivecore.util.TimeDiffUtil;
|
import com.massivecraft.massivecore.util.TimeDiffUtil;
|
||||||
import com.massivecraft.massivecore.util.TimeUnit;
|
import com.massivecraft.massivecore.util.TimeUnit;
|
||||||
@ -61,13 +62,9 @@ public class CmdFactionsStatus extends FactionsCommand
|
|||||||
final List<MPlayer> mplayers = faction.getMPlayers();
|
final List<MPlayer> mplayers = faction.getMPlayers();
|
||||||
Collections.sort(mplayers, sortedBy);
|
Collections.sort(mplayers, sortedBy);
|
||||||
|
|
||||||
// Create Pager
|
// Pager Create
|
||||||
final PagerSimple<MPlayer> pager = new PagerSimple<MPlayer>(mplayers, sender);
|
String title = Txt.parse("<i>Status of %s<i>.", faction.describeTo(msender, true));
|
||||||
String pagerTitle = Txt.parse("<i>Status of %s<i>.", faction.describeTo(msender, true));
|
final Pager<MPlayer> pager = new Pager<MPlayer>(this, title, page, mplayers, new Stringifier<MPlayer>(){
|
||||||
|
|
||||||
// Use Pager
|
|
||||||
List<String> messages = pager.getPageTxt(page, pagerTitle, new Stringifier<MPlayer>(){
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString(MPlayer mplayer, int index)
|
public String toString(MPlayer mplayer, int index)
|
||||||
{
|
{
|
||||||
@ -109,11 +106,11 @@ public class CmdFactionsStatus extends FactionsCommand
|
|||||||
|
|
||||||
return Txt.parse("%s%s %s %s", displayName, whiteSpace, power, lastActive);
|
return Txt.parse("%s%s %s %s", displayName, whiteSpace, power, lastActive);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Send message
|
|
||||||
message(messages);
|
// Pager Message
|
||||||
|
pager.message();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user