mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-04 23:37:49 +01:00
Centralizing auto pagination
This commit is contained in:
parent
8bdd49d988
commit
5c1321ecd4
@ -1471,50 +1471,6 @@ public final class Jobs extends JavaPlugin {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showPagination(CommandSender sender, PageInfo pi, String cmd) {
|
|
||||||
showPagination(sender, pi.getTotalPages(), pi.getCurrentPage(), pi.getTotalEntries(), cmd, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void showPagination(CommandSender sender, PageInfo pi, String cmd, String pagePref) {
|
|
||||||
showPagination(sender, pi.getTotalPages(), pi.getCurrentPage(), pi.getTotalEntries(), cmd, pagePref);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void showPagination(CommandSender sender, int pageCount, int currentPage, int totalEntries, String cmd, String pagePref) {
|
|
||||||
if (!(sender instanceof Player))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!cmd.startsWith("/"))
|
|
||||||
cmd = "/" + cmd;
|
|
||||||
|
|
||||||
if (pageCount == 1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
String pagePrefix = pagePref == null ? "" : pagePref;
|
|
||||||
|
|
||||||
int nextPage = currentPage + 1;
|
|
||||||
nextPage = currentPage < pageCount ? nextPage : currentPage;
|
|
||||||
|
|
||||||
int prevpage = currentPage - 1;
|
|
||||||
if (currentPage <= 1) {
|
|
||||||
prevpage = currentPage;
|
|
||||||
}
|
|
||||||
|
|
||||||
RawMessage rm = new RawMessage()
|
|
||||||
.addText((currentPage > 1 ? LC.info_prevPage.getLocale() : LC.info_prevPageOff.getLocale()))
|
|
||||||
.addHover(currentPage > 1 ? LC.info_prevPageHover.getLocale() : LC.info_lastPageHover.getLocale())
|
|
||||||
.addCommand(currentPage > 1 ? cmd + " " + pagePrefix + prevpage : cmd + " " + pagePrefix + pageCount);
|
|
||||||
|
|
||||||
rm.addText(LC.info_pageCount.getLocale("[current]", currentPage, "[total]", pageCount))
|
|
||||||
.addHover(LC.info_pageCountHover.getLocale("[totalEntries]", totalEntries));
|
|
||||||
|
|
||||||
rm.addText(pageCount > currentPage ? LC.info_nextPage.getLocale() : LC.info_nextPageOff.getLocale())
|
|
||||||
.addHover(pageCount > currentPage ? LC.info_nextPageHover.getLocale() : LC.info_firstPageHover.getLocale())
|
|
||||||
.addCommand(pageCount > currentPage ? cmd + " " + pagePrefix + nextPage : cmd + " " + pagePrefix + 1);
|
|
||||||
|
|
||||||
if (pageCount != 0)
|
|
||||||
rm.show(sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean hasLimitedItems() {
|
public static boolean hasLimitedItems() {
|
||||||
return hasLimitedItems;
|
return hasLimitedItems;
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,8 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.gamingmesh.jobs.Jobs;
|
import com.gamingmesh.jobs.Jobs;
|
||||||
|
import com.gamingmesh.jobs.commands.list.info;
|
||||||
|
import com.gamingmesh.jobs.commands.list.playerinfo;
|
||||||
import com.gamingmesh.jobs.container.ActionType;
|
import com.gamingmesh.jobs.container.ActionType;
|
||||||
import com.gamingmesh.jobs.container.Boost;
|
import com.gamingmesh.jobs.container.Boost;
|
||||||
import com.gamingmesh.jobs.container.CurrencyType;
|
import com.gamingmesh.jobs.container.CurrencyType;
|
||||||
@ -28,7 +30,6 @@ import net.Zrips.CMILib.ActionBar.CMIActionBar;
|
|||||||
import net.Zrips.CMILib.Container.CMIArray;
|
import net.Zrips.CMILib.Container.CMIArray;
|
||||||
import net.Zrips.CMILib.Container.PageInfo;
|
import net.Zrips.CMILib.Container.PageInfo;
|
||||||
import net.Zrips.CMILib.Locale.LC;
|
import net.Zrips.CMILib.Locale.LC;
|
||||||
import net.Zrips.CMILib.Logs.CMIDebug;
|
|
||||||
import net.Zrips.CMILib.Messages.CMIMessages;
|
import net.Zrips.CMILib.Messages.CMIMessages;
|
||||||
import net.Zrips.CMILib.RawMessages.RawMessage;
|
import net.Zrips.CMILib.RawMessages.RawMessage;
|
||||||
|
|
||||||
@ -162,18 +163,12 @@ public class JobsCommands implements CommandExecutor {
|
|||||||
|
|
||||||
boolean pl = sender instanceof Player;
|
boolean pl = sender instanceof Player;
|
||||||
|
|
||||||
// Old format
|
|
||||||
// sender.sendMessage(Jobs.getLanguage().getMessage("command.help.output.title"));
|
|
||||||
for (String one : commands) {
|
for (String one : commands) {
|
||||||
if (!pi.isEntryOk())
|
if (!pi.isEntryOk())
|
||||||
continue;
|
continue;
|
||||||
if (pi.isBreak())
|
if (pi.isBreak())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Old format
|
|
||||||
// sender.sendMessage(Jobs.getLanguage().getMessage("command.help.output.cmdInfoFormat", "[command]", getUsage(one), "[description]", Jobs.getLanguage().getMessage("command." + one
|
|
||||||
// + ".help.info")));
|
|
||||||
|
|
||||||
if (pl) {
|
if (pl) {
|
||||||
rm.addText("\n" + getUsage(one));
|
rm.addText("\n" + getUsage(one));
|
||||||
rm.addHover(Jobs.getLanguage().getMessage("command." + one + ".help.info"));
|
rm.addHover(Jobs.getLanguage().getMessage("command." + one + ".help.info"));
|
||||||
@ -182,12 +177,10 @@ public class JobsCommands implements CommandExecutor {
|
|||||||
rm.addText("\n" + Jobs.getLanguage().getMessage("command.help.output.cmdInfoFormat", "[command]", getUsage(one), "[description]", Jobs.getLanguage().getMessage("command." + one
|
rm.addText("\n" + Jobs.getLanguage().getMessage("command.help.output.cmdInfoFormat", "[command]", getUsage(one), "[description]", Jobs.getLanguage().getMessage("command." + one
|
||||||
+ ".help.info")));
|
+ ".help.info")));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rm.show(sender);
|
rm.show(sender);
|
||||||
|
|
||||||
plugin.showPagination(sender, pi, LABEL + " ?");
|
pi.autoPagination(sender, LABEL + " ?");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,9 +326,9 @@ public class JobsCommands implements CommandExecutor {
|
|||||||
String pName = player.getName();
|
String pName = player.getName();
|
||||||
|
|
||||||
if (sender.getName().equalsIgnoreCase(pName))
|
if (sender.getName().equalsIgnoreCase(pName))
|
||||||
plugin.showPagination(sender, pi, "jobs info " + job.getName() + t);
|
pi.autoPagination(sender, LABEL + " " + info.class.getSimpleName() + " " + job.getName() + t);
|
||||||
else
|
else
|
||||||
plugin.showPagination(sender, pi, "jobs playerinfo " + pName + " " + job.getName() + t);
|
pi.autoPagination(sender, LABEL + " " + playerinfo.class.getSimpleName() + " " + job.getName() + t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -356,11 +349,11 @@ public class JobsCommands implements CommandExecutor {
|
|||||||
message.append(":\n");
|
message.append(":\n");
|
||||||
|
|
||||||
JobProgression prog = player.getJobProgression(job);
|
JobProgression prog = player.getJobProgression(job);
|
||||||
|
|
||||||
if (prog == null) {
|
if (prog == null) {
|
||||||
prog = player.getArchivedJobProgression(job);
|
prog = player.getArchivedJobProgression(job);
|
||||||
}
|
}
|
||||||
|
|
||||||
int level = prog != null ? prog.getLevel() : 1;
|
int level = prog != null ? prog.getLevel() : 1;
|
||||||
int numjobs = player.progression.size();
|
int numjobs = player.progression.size();
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ public class browse implements Cmd {
|
|||||||
|
|
||||||
rm.show(sender);
|
rm.show(sender);
|
||||||
}
|
}
|
||||||
plugin.showPagination(sender, pi, "jobs browse", "-p:");
|
pi.autoPagination(sender, "jobs browse", "-p:");
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.jobHeader", "[jobname]", j.getName()));
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.jobHeader", "[jobname]", j.getName()));
|
||||||
|
@ -117,7 +117,7 @@ public class editjobs implements Cmd {
|
|||||||
rm.show(sender);
|
rm.show(sender);
|
||||||
Util.getJobsEditorMap().remove(player.getUniqueId());
|
Util.getJobsEditorMap().remove(player.getUniqueId());
|
||||||
|
|
||||||
plugin.showPagination(sender, pi, "jobs editjobs list " + job.getName() + " " + actionT.getName());
|
pi.autoPagination(sender, "jobs editjobs list " + job.getName() + " " + actionT.getName());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,79 +20,79 @@ public class gtop implements Cmd {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
|
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
CMIMessages.sendMessage(sender, LC.info_Ingame);
|
CMIMessages.sendMessage(sender, LC.info_Ingame);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
Jobs.getCommandManager().sendUsage(sender, "gtop");
|
Jobs.getCommandManager().sendUsage(sender, "gtop");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
int page = 1;
|
int page = 1;
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
if (args[0].equalsIgnoreCase("clear")) {
|
if (args[0].equalsIgnoreCase("clear")) {
|
||||||
player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
|
player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
|
||||||
CMIScoreboard.removeScoreBoard(player);
|
CMIScoreboard.removeScoreBoard(player);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
page = Integer.parseInt(args[0]);
|
page = Integer.parseInt(args[0]);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (page < 1)
|
if (page < 1)
|
||||||
page = 1;
|
page = 1;
|
||||||
|
|
||||||
int amount = Jobs.getGCManager().JobsTopAmount;
|
int amount = Jobs.getGCManager().JobsTopAmount;
|
||||||
PageInfo pi = new PageInfo(amount, Jobs.getPlayerManager().getPlayersCache().size(), page);
|
PageInfo pi = new PageInfo(amount, Jobs.getPlayerManager().getPlayersCache().size(), page);
|
||||||
|
|
||||||
List<TopList> FullList = Jobs.getJobsDAO().getGlobalTopList(pi.getStart());
|
List<TopList> FullList = Jobs.getJobsDAO().getGlobalTopList(pi.getStart());
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Jobs.getGCManager().ShowToplistInScoreboard) {
|
if (!Jobs.getGCManager().ShowToplistInScoreboard) {
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.gtop.output.topline", "%amount%", amount));
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.gtop.output.topline", "%amount%", amount));
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (TopList One : FullList) {
|
for (TopList One : FullList) {
|
||||||
if (i >= amount)
|
if (i >= amount)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.gtop.output.list",
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.gtop.output.list",
|
||||||
"%number%", pi.getPositionForOutput(i),
|
"%number%", pi.getPositionForOutput(i),
|
||||||
"%playername%", One.getPlayerInfo().getName(),
|
"%playername%", One.getPlayerInfo().getName(),
|
||||||
"%playerdisplayname%", One.getPlayerInfo().getDisplayName(),
|
"%playerdisplayname%", One.getPlayerInfo().getDisplayName(),
|
||||||
"%level%", One.getLevel(),
|
"%level%", One.getLevel(),
|
||||||
"%exp%", One.getExp()));
|
"%exp%", One.getExp()));
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
List<String> ls = new ArrayList<>();
|
List<String> ls = new ArrayList<>();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (TopList one : FullList) {
|
for (TopList one : FullList) {
|
||||||
if (i >= amount)
|
if (i >= amount)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
ls.add(Jobs.getLanguage().getMessage("scoreboard.line",
|
ls.add(Jobs.getLanguage().getMessage("scoreboard.line",
|
||||||
"%number%", pi.getPositionForOutput(i),
|
"%number%", pi.getPositionForOutput(i),
|
||||||
"%playername%", one.getPlayerInfo().getName(),
|
"%playername%", one.getPlayerInfo().getName(),
|
||||||
"%playerdisplayname%", one.getPlayerInfo().getDisplayName(),
|
"%playerdisplayname%", one.getPlayerInfo().getDisplayName(),
|
||||||
"%level%", one.getLevel()));
|
"%level%", one.getLevel()));
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|
||||||
CMIScoreboard.show(player, Jobs.getLanguage().getMessage("scoreboard.gtopline"), ls, Jobs.getGCManager().ToplistInScoreboardInterval);
|
CMIScoreboard.show(player, Jobs.getLanguage().getMessage("scoreboard.gtopline"), ls, Jobs.getGCManager().ToplistInScoreboardInterval);
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.showPagination(sender, pi, "jobs gtop");
|
pi.autoPagination(sender, "jobs gtop");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,61 +16,61 @@ public class placeholders implements Cmd {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
|
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
|
||||||
boolean isPlayer = sender instanceof Player;
|
boolean isPlayer = sender instanceof Player;
|
||||||
Player player = isPlayer ? (Player) sender : null;
|
Player player = isPlayer ? (Player) sender : null;
|
||||||
|
|
||||||
int page = 1;
|
int page = 1;
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
if (isPlayer) {
|
if (isPlayer) {
|
||||||
if (args[0].startsWith("-p:")) {
|
if (args[0].startsWith("-p:")) {
|
||||||
try {
|
try {
|
||||||
page = Integer.parseInt(args[0].substring("-p:".length()));
|
page = Integer.parseInt(args[0].substring("-p:".length()));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
player = Bukkit.getPlayer(args[0]);
|
player = Bukkit.getPlayer(args[0]);
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
Jobs.consoleMsg("&cPlayer cannot be null!");
|
Jobs.consoleMsg("&cPlayer cannot be null!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length >= 2 && args[0].equalsIgnoreCase("parse")) {
|
if (args.length >= 2 && args[0].equalsIgnoreCase("parse")) {
|
||||||
String placeholder = args[1];
|
String placeholder = args[1];
|
||||||
JobsPlaceholderType type = plugin.getPlaceholderAPIManager().getPlaceHolderType(player, placeholder);
|
JobsPlaceholderType type = plugin.getPlaceholderAPIManager().getPlaceHolderType(player, placeholder);
|
||||||
|
|
||||||
sender.sendMessage(Jobs.getLanguage().getMessage("command.placeholders.output.parse",
|
sender.sendMessage(Jobs.getLanguage().getMessage("command.placeholders.output.parse",
|
||||||
"[placeholder]", placeholder,
|
"[placeholder]", placeholder,
|
||||||
"[source]", type == null ? "Unknown" : type.name(),
|
"[source]", type == null ? "Unknown" : type.name(),
|
||||||
"[result]", plugin.getPlaceholderAPIManager().updatePlaceHolders(player, placeholder)));
|
"[result]", plugin.getPlaceholderAPIManager().updatePlaceHolders(player, placeholder)));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
JobsPlaceHolders[] values = JobsPlaceHolders.values();
|
JobsPlaceHolders[] values = JobsPlaceHolders.values();
|
||||||
PageInfo pi = new PageInfo(isPlayer ? Jobs.getGCManager().PlaceholdersPage : values.length, values.length, page);
|
PageInfo pi = new PageInfo(isPlayer ? Jobs.getGCManager().PlaceholdersPage : values.length, values.length, page);
|
||||||
|
|
||||||
for (JobsPlaceHolders one : values) {
|
for (JobsPlaceHolders one : values) {
|
||||||
if (pi.isBreak())
|
if (pi.isBreak())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!pi.isEntryOk())
|
if (!pi.isEntryOk())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
RawMessage rm = new RawMessage();
|
RawMessage rm = new RawMessage();
|
||||||
String extra = "";
|
String extra = "";
|
||||||
|
|
||||||
if (player != null && !one.isComplex())
|
if (player != null && !one.isComplex())
|
||||||
extra = plugin.getPlaceholderAPIManager().updatePlaceHolders(player, Jobs.getLanguage().getMessage("command.placeholders.output.outputResult",
|
extra = plugin.getPlaceholderAPIManager().updatePlaceHolders(player, Jobs.getLanguage().getMessage("command.placeholders.output.outputResult",
|
||||||
"[result]", plugin.getPlaceholderAPIManager().updatePlaceHolders(player, one.getFull())));
|
"[result]", plugin.getPlaceholderAPIManager().updatePlaceHolders(player, one.getFull())));
|
||||||
|
|
||||||
String place = one.getFull();
|
String place = one.getFull();
|
||||||
String hover = "";
|
String hover = "";
|
||||||
if (plugin.isPlaceholderAPIEnabled()) {
|
if (plugin.isPlaceholderAPIEnabled()) {
|
||||||
hover = place = one.getFull();
|
hover = place = one.getFull();
|
||||||
}
|
}
|
||||||
// For MVdWPlaceholderAPI
|
// For MVdWPlaceholderAPI
|
||||||
// if (plugin.isMVdWPlaceholderAPIEnabled()) {
|
// if (plugin.isMVdWPlaceholderAPIEnabled()) {
|
||||||
// if (!plugin.isPlaceholderAPIEnabled()) {
|
// if (!plugin.isPlaceholderAPIEnabled()) {
|
||||||
@ -82,12 +82,12 @@ public class placeholders implements Cmd {
|
|||||||
// else
|
// else
|
||||||
// hover += "\n" + "{" + one.getFull().substring(1, one.getFull().length() - 2) + "}";
|
// hover += "\n" + "{" + one.getFull().substring(1, one.getFull().length() - 2) + "}";
|
||||||
// }
|
// }
|
||||||
rm.addText(Jobs.getLanguage().getMessage("command.placeholders.output.list", "[place]", pi.getPositionForOutput(), "[placeholder]", place) + extra)
|
rm.addText(Jobs.getLanguage().getMessage("command.placeholders.output.list", "[place]", pi.getPositionForOutput(), "[placeholder]", place) + extra)
|
||||||
.addHover(hover).addSuggestion(one.getFull()).show(sender);
|
.addHover(hover).addSuggestion(one.getFull()).show(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player != null)
|
if (player != null)
|
||||||
plugin.showPagination(sender, pi, "jobs placeholders", "-p:");
|
pi.autoPagination(sender, "jobs placeholders", "-p:");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,83 +21,83 @@ public class top implements Cmd {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
|
public boolean perform(Jobs plugin, final CommandSender sender, final String[] args) {
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
CMIMessages.sendMessage(sender, LC.info_Ingame);
|
CMIMessages.sendMessage(sender, LC.info_Ingame);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length != 1 && args.length != 2) {
|
if (args.length != 1 && args.length != 2) {
|
||||||
Jobs.getCommandManager().sendUsage(sender, "top");
|
Jobs.getCommandManager().sendUsage(sender, "top");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
if (args[0].equalsIgnoreCase("clear")) {
|
if (args[0].equalsIgnoreCase("clear")) {
|
||||||
player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
|
player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
|
||||||
CMIScoreboard.removeScoreBoard(player);
|
CMIScoreboard.removeScoreBoard(player);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int page = 1;
|
int page = 1;
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
try {
|
try {
|
||||||
page = Integer.parseInt(args[1]);
|
page = Integer.parseInt(args[1]);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (page < 1)
|
if (page < 1)
|
||||||
page = 1;
|
page = 1;
|
||||||
|
|
||||||
Job job = Jobs.getJob(args[0]);
|
Job job = Jobs.getJob(args[0]);
|
||||||
if (job == null) {
|
if (job == null) {
|
||||||
player.sendMessage(Jobs.getLanguage().getMessage("command.top.error.nojob"));
|
player.sendMessage(Jobs.getLanguage().getMessage("command.top.error.nojob"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int workingIn = Jobs.getUsedSlots(job);
|
int workingIn = Jobs.getUsedSlots(job);
|
||||||
PageInfo pi = new PageInfo(Jobs.getGCManager().JobsTopAmount, workingIn, page);
|
PageInfo pi = new PageInfo(Jobs.getGCManager().JobsTopAmount, workingIn, page);
|
||||||
|
|
||||||
List<TopList> fullList = Jobs.getJobsDAO().toplist(job.getName(), pi.getStart());
|
List<TopList> fullList = Jobs.getJobsDAO().toplist(job.getName(), pi.getStart());
|
||||||
if (fullList.isEmpty()) {
|
if (fullList.isEmpty()) {
|
||||||
CMIMessages.sendMessage(sender, LC.info_NoInformation);
|
CMIMessages.sendMessage(sender, LC.info_NoInformation);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage(Jobs.getLanguage().getMessage("command.top.help.info"));
|
player.sendMessage(Jobs.getLanguage().getMessage("command.top.help.info"));
|
||||||
|
|
||||||
int place = 1;
|
int place = 1;
|
||||||
|
|
||||||
if (!Jobs.getGCManager().ShowToplistInScoreboard) {
|
if (!Jobs.getGCManager().ShowToplistInScoreboard) {
|
||||||
player.sendMessage(Jobs.getLanguage().getMessage("command.top.output.topline", "%jobname%", job.getName(), "%amount%", Jobs.getGCManager().JobsTopAmount));
|
player.sendMessage(Jobs.getLanguage().getMessage("command.top.output.topline", "%jobname%", job.getName(), "%amount%", Jobs.getGCManager().JobsTopAmount));
|
||||||
for (TopList one : fullList) {
|
for (TopList one : fullList) {
|
||||||
if (place > Jobs.getGCManager().JobsTopAmount)
|
if (place > Jobs.getGCManager().JobsTopAmount)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
player.sendMessage(Jobs.getLanguage().getMessage("command.top.output.list",
|
player.sendMessage(Jobs.getLanguage().getMessage("command.top.output.list",
|
||||||
"%number%", ((page - 1) * Jobs.getGCManager().JobsTopAmount) + place,
|
"%number%", ((page - 1) * Jobs.getGCManager().JobsTopAmount) + place,
|
||||||
"%playername%", one.getPlayerInfo().getName(),
|
"%playername%", one.getPlayerInfo().getName(),
|
||||||
"%playerdisplayname%", one.getPlayerInfo().getDisplayName(),
|
"%playerdisplayname%", one.getPlayerInfo().getDisplayName(),
|
||||||
"%level%", one.getLevel(),
|
"%level%", one.getLevel(),
|
||||||
"%exp%", one.getExp()));
|
"%exp%", one.getExp()));
|
||||||
place++;
|
place++;
|
||||||
}
|
}
|
||||||
plugin.showPagination(sender, pi, "jobs top " + job.getName());
|
pi.autoPagination(sender, "jobs top " + job.getName());
|
||||||
} else {
|
} else {
|
||||||
List<String> ls = new ArrayList<>();
|
List<String> ls = new ArrayList<>();
|
||||||
|
|
||||||
for (TopList one : fullList) {
|
for (TopList one : fullList) {
|
||||||
if (place > Jobs.getGCManager().JobsTopAmount)
|
if (place > Jobs.getGCManager().JobsTopAmount)
|
||||||
break;
|
break;
|
||||||
ls.add(Jobs.getLanguage().getMessage("scoreboard.line", "%number%", ((page - 1) * Jobs.getGCManager().JobsTopAmount) + place,
|
ls.add(Jobs.getLanguage().getMessage("scoreboard.line", "%number%", ((page - 1) * Jobs.getGCManager().JobsTopAmount) + place,
|
||||||
"%playername%", one.getPlayerInfo().getName(), "%playerdisplayname%", one.getPlayerInfo().getDisplayName(), "%level%", one.getLevel()));
|
"%playername%", one.getPlayerInfo().getName(), "%playerdisplayname%", one.getPlayerInfo().getDisplayName(), "%level%", one.getLevel()));
|
||||||
place++;
|
place++;
|
||||||
}
|
}
|
||||||
|
|
||||||
CMIScoreboard.show(player, Jobs.getLanguage().getMessage("scoreboard.topline", "%jobname%", job.getName()), ls, Jobs.getGCManager().ToplistInScoreboardInterval);
|
CMIScoreboard.show(player, Jobs.getLanguage().getMessage("scoreboard.topline", "%jobname%", job.getName()), ls, Jobs.getGCManager().ToplistInScoreboardInterval);
|
||||||
|
|
||||||
plugin.showPagination(sender, pi, "jobs top " + job.getName());
|
pi.autoPagination(sender, "jobs top " + job.getName());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user