1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 22:13:25 +01:00

Lets use PageInfo if we want to have correct pagination for top and gtop

This commit is contained in:
Zrips 2020-02-15 15:52:01 +02:00
parent a1c2274b1b
commit 11bcc004e5

View File

@ -47,7 +47,7 @@ public class gtop implements Cmd {
PageInfo pi = new PageInfo(Jobs.getGCManager().JobsTopAmount, Jobs.getPlayerManager().getPlayersCache().size(), page); PageInfo pi = new PageInfo(Jobs.getGCManager().JobsTopAmount, Jobs.getPlayerManager().getPlayersCache().size(), page);
List<TopList> FullList = Jobs.getJobsDAO().getGlobalTopList(pi.getStart()); List<TopList> FullList = Jobs.getJobsDAO().getGlobalTopList(pi.getStart() - 1);
if (FullList.isEmpty()) { if (FullList.isEmpty()) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.gtop.error.nojob")); sender.sendMessage(Jobs.getLanguage().getMessage("command.gtop.error.nojob"));
return true; return true;
@ -55,12 +55,18 @@ public class gtop implements Cmd {
if (!Jobs.getGCManager().ShowToplistInScoreboard) { if (!Jobs.getGCManager().ShowToplistInScoreboard) {
sender.sendMessage(Jobs.getLanguage().getMessage("command.gtop.output.topline", "%amount%", Jobs.getGCManager().JobsTopAmount)); sender.sendMessage(Jobs.getLanguage().getMessage("command.gtop.output.topline", "%amount%", Jobs.getGCManager().JobsTopAmount));
int i = pi.getStart();
for (TopList One : FullList) { for (TopList One : FullList) {
i++;
if (pi.isBreak())
break;
if (pi.isContinue())
continue;
String PlayerName = One.getPlayerName() != null ? One.getPlayerName() : "Unknown"; String PlayerName = One.getPlayerName() != null ? One.getPlayerName() : "Unknown";
sender.sendMessage(Jobs.getLanguage().getMessage("command.gtop.output.list", sender.sendMessage(Jobs.getLanguage().getMessage("command.gtop.output.list",
"%number%", i, "%number%", pi.getPositionForOutput(),
"%playername%", PlayerName, "%playername%", PlayerName,
"%level%", One.getLevel(), "%level%", One.getLevel(),
"%exp%", One.getExp())); "%exp%", One.getExp()));
@ -71,12 +77,17 @@ public class gtop implements Cmd {
List<String> ls = new ArrayList<>(); List<String> ls = new ArrayList<>();
int i = pi.getStart();
for (TopList one : FullList) { for (TopList one : FullList) {
i++;
if (pi.isBreak())
break;
if (pi.isContinue())
continue;
String playername = one.getPlayerName() != null ? one.getPlayerName() : "Unknown"; String playername = one.getPlayerName() != null ? one.getPlayerName() : "Unknown";
ls.add(Jobs.getLanguage().getMessage("scoreboard.line", ls.add(Jobs.getLanguage().getMessage("scoreboard.line",
"%number%", i, "%number%", pi.getPositionForOutput(),
"%playername%", playername, "%playername%", playername,
"%level%", one.getLevel())); "%level%", one.getLevel()));
} }