diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/browse.java b/src/main/java/com/gamingmesh/jobs/commands/list/browse.java index b8904773..00ca3196 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/browse.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/browse.java @@ -1,7 +1,6 @@ package com.gamingmesh.jobs.commands.list; import java.util.ArrayList; -import java.util.Calendar; import java.util.List; import org.bukkit.command.CommandSender; @@ -13,7 +12,6 @@ import com.gamingmesh.jobs.commands.Cmd; import com.gamingmesh.jobs.commands.JobCommand; import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.stuff.ChatColor; -import com.gamingmesh.jobs.stuff.Debug; import com.gamingmesh.jobs.stuff.PageInfo; import com.gamingmesh.jobs.stuff.RawMessage; @@ -23,192 +21,196 @@ public class browse implements Cmd { @JobCommand(200) public boolean perform(Jobs plugin, CommandSender sender, final String[] args) { - List jobList = new ArrayList(Jobs.getJobs()); + if (Jobs.getGCManager().BrowseUseNewLook) { + List jobList = new ArrayList(Jobs.getJobs()); - if (jobList.size() == 0) { - sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("command.browse.error.nojobs")); - return true; - } - - if (sender instanceof Player && Jobs.getGCManager().JobsGUIOpenOnBrowse) { - Inventory inv = null; - try { - inv = Jobs.getGUIManager().CreateJobsGUI((Player) sender); - } catch (Exception e) { - ((Player) sender).closeInventory(); - Jobs.getGUIManager().GuiList.remove(((Player) sender).getName()); + if (jobList.size() == 0) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("command.browse.error.nojobs")); return true; } - if (inv == null) + + if (sender instanceof Player && Jobs.getGCManager().JobsGUIOpenOnBrowse) { + Inventory inv = null; + try { + inv = Jobs.getGUIManager().CreateJobsGUI((Player) sender); + } catch (Exception e) { + ((Player) sender).closeInventory(); + Jobs.getGUIManager().GuiList.remove(((Player) sender).getName()); + return true; + } + if (inv == null) + return true; + ((Player) sender).openInventory(inv); return true; - ((Player) sender).openInventory(inv); - return true; - } + } - int page = 1; - Job j = null; - for (String one : args) { - if (one.startsWith("-p:")) { - try { - page = Integer.parseInt(one.substring("-p:".length())); - continue; - } catch (Exception e) { + int page = 1; + Job j = null; + for (String one : args) { + if (one.startsWith("-p:")) { + try { + page = Integer.parseInt(one.substring("-p:".length())); + continue; + } catch (Exception e) { + } + } + if (one.startsWith("-j:")) { + try { + j = Jobs.getJob(one.substring("-j:".length())); + continue; + } catch (Exception e) { + } } } - if (one.startsWith("-j:")) { - try { - j = Jobs.getJob(one.substring("-j:".length())); - continue; - } catch (Exception e) { - } - } - } - if (j == null) { - PageInfo pi = new PageInfo(Jobs.getGCManager().getBrowseAmountToShow(), jobList.size(), page); - sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.newHeader", "[amount]", jobList.size())); - for (Job one : jobList) { - if (!pi.isEntryOk()) - continue; - if (pi.isBreak()) - break; + if (j == null) { + PageInfo pi = new PageInfo(Jobs.getGCManager().getBrowseAmountToShow(), jobList.size(), page); + sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.newHeader", "[amount]", jobList.size())); + for (Job one : jobList) { + if (!pi.isEntryOk()) + continue; + if (pi.isBreak()) + break; - RawMessage rm = new RawMessage(); + RawMessage rm = new RawMessage(); - String hoverMsg = ""; + String hoverMsg = ""; + + if (!one.getDescription().isEmpty()) { + hoverMsg += one.getDescription().replace("/n", ""); + } + if (one.getMaxLevel(sender) > 0) { + if (!hoverMsg.isEmpty()) + hoverMsg += " \n"; + hoverMsg += Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", one.getMaxLevel(sender)); + } + + if (Jobs.getGCManager().ShowTotalWorkers) { + if (!hoverMsg.isEmpty()) + hoverMsg += " \n"; + hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", one.getTotalPlayers()); + + } + + if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) { + if (!hoverMsg.isEmpty()) + hoverMsg += " \n"; + if ((int) (one.getBonus() * 100) < 0) + hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", (int) (one.getBonus() * 100) * -1); + else + hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (one.getBonus() * 100)); + } - if (!one.getDescription().isEmpty()) { - hoverMsg += one.getDescription().replace("/n", ""); - } - if (one.getMaxLevel(sender) > 0) { if (!hoverMsg.isEmpty()) hoverMsg += " \n"; - hoverMsg += Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", one.getMaxLevel(sender)); + hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.click"); + + rm.add(Jobs.getLanguage().getMessage("command.browse.output.list", "[place]", pi.getPositionForOutput(), "[jobname]", one.getName()), + hoverMsg, "jobs browse -j:" + one.getName()); + + rm.show(sender); + } + plugin.ShowPagination(sender, pi.getTotalPages(), page, "jobs browse", "-p:"); + } else { + + sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.jobHeader", "[jobname]", j.getName())); + + if (j.getMaxLevel(sender) > 0) { + sender.sendMessage(Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", j.getMaxLevel(sender))); } if (Jobs.getGCManager().ShowTotalWorkers) { - if (!hoverMsg.isEmpty()) - hoverMsg += " \n"; - hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", one.getTotalPlayers()); + sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", j.getTotalPlayers())); } if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) { - if (!hoverMsg.isEmpty()) - hoverMsg += " \n"; - if ((int) (one.getBonus() * 100) < 0) - hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", (int) (one.getBonus() * 100) * -1); + if ((int) (j.getBonus() * 100) < 0) + sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", (int) (j.getBonus() * 100) * -1)); else - hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (one.getBonus() * 100)); + sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (j.getBonus() * 100))); } - if (!hoverMsg.isEmpty()) - hoverMsg += " \n"; - hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.click"); - - rm.add(Jobs.getLanguage().getMessage("command.browse.output.list", "[place]", pi.getPositionForOutput(), "[jobname]", one.getName()), - hoverMsg, "jobs browse -j:" + one.getName()); + if (!j.getFullDescription().isEmpty()) + for (String one : j.getFullDescription()) { + sender.sendMessage(one); + } + RawMessage rm = new RawMessage(); + rm.add(Jobs.getLanguage().getMessage("command.browse.output.detailed"), + Jobs.getLanguage().getMessage("command.browse.output.detailed"), + "jobs info " + j.getName()); + rm.show(sender); + rm.clear(); + rm.add(Jobs.getLanguage().getMessage("command.browse.output.chooseJob"), + Jobs.getLanguage().getMessage("command.browse.output.chooseJobHover"), + "jobs join " + j.getName() + " -needConfirmation"); rm.show(sender); } - plugin.ShowPagination(sender, pi.getTotalPages(), page, "jobs browse", "-p:"); + } else { - sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.jobHeader", "[jobname]", j.getName())); - - if (j.getMaxLevel(sender) > 0) { - sender.sendMessage(Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", j.getMaxLevel(sender))); - } - - if (Jobs.getGCManager().ShowTotalWorkers) { - sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", j.getTotalPlayers())); - - } - - if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) { - if ((int) (j.getBonus() * 100) < 0) - sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", (int) (j.getBonus() * 100) * -1)); - else - sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (j.getBonus() * 100))); - } - - if (!j.getFullDescription().isEmpty()) - for (String one : j.getFullDescription()) { - sender.sendMessage(one); + ArrayList lines = new ArrayList(); + for (Job job : Jobs.getJobs()) { + if (Jobs.getGCManager().getHideJobsWithoutPermission()) { + if (!Jobs.getCommandManager().hasJobPermission(sender, job)) + continue; + } + StringBuilder builder = new StringBuilder(); + builder.append(" "); + builder.append(job.getChatColor().toString()); + builder.append(job.getName()); + if (job.getMaxLevel(sender) > 0) { + builder.append(ChatColor.WHITE.toString()); + builder.append(Jobs.getLanguage().getMessage("command.info.help.max")); + builder.append(job.getMaxLevel(sender)); } - RawMessage rm = new RawMessage(); - rm.add(Jobs.getLanguage().getMessage("command.browse.output.detailed"), - Jobs.getLanguage().getMessage("command.browse.output.detailed"), - "jobs info " + j.getName()); - rm.show(sender); - rm.clear(); - rm.add(Jobs.getLanguage().getMessage("command.browse.output.chooseJob"), - Jobs.getLanguage().getMessage("command.browse.output.chooseJobHover"), - "jobs join " + j.getName() + " -needConfirmation"); - rm.show(sender); + if (Jobs.getGCManager().ShowTotalWorkers) + builder.append(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", job.getTotalPlayers())); + + if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) + if (job.getBonus() < 0) + builder.append(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", (int) (job.getBonus() * 100) * -1)); + else + builder.append(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (job.getBonus() * 100))); + + lines.add(builder.toString()); + if (!job.getDescription().isEmpty()) { + lines.add(" - " + job.getDescription().replace("/n", "")); + } + } + + if (lines.size() == 0) { + sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("command.browse.error.nojobs")); + return true; + } + + if (sender instanceof Player && Jobs.getGCManager().JobsGUIOpenOnBrowse) { + + Inventory inv = null; + try { + inv = Jobs.getGUIManager().CreateJobsGUI((Player) sender); + } catch (Exception e) { + ((Player) sender).closeInventory(); + Jobs.getGUIManager().GuiList.remove(((Player) sender).getName()); + return true; + } + if (inv == null) + return true; + + ((Player) sender).openInventory(inv); + + } + + if (Jobs.getGCManager().JobsGUIShowChatBrowse) { + sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.header")); + for (String line : lines) { + sender.sendMessage(line); + } + sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.footer")); + } } -// -// ArrayList lines = new ArrayList(); -// for (Job job : Jobs.getJobs()) { -// if (Jobs.getGCManager().getHideJobsWithoutPermission()) { -// if (!Jobs.getCommandManager().hasJobPermission(sender, job)) -// continue; -// } -// StringBuilder builder = new StringBuilder(); -// builder.append(" "); -// builder.append(job.getChatColor().toString()); -// builder.append(job.getName()); -// if (job.getMaxLevel(sender) > 0) { -// builder.append(ChatColor.WHITE.toString()); -// builder.append(Jobs.getLanguage().getMessage("command.info.help.max")); -// builder.append(job.getMaxLevel(sender)); -// } -// -// if (Jobs.getGCManager().ShowTotalWorkers) -// builder.append(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", job.getTotalPlayers())); -// -// if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) -// if (job.getBonus() < 0) -// builder.append(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", (int) (job.getBonus() * 100) * -1)); -// else -// builder.append(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (job.getBonus() * 100))); -// -// lines.add(builder.toString()); -// if (!job.getDescription().isEmpty()) { -// lines.add(" - " + job.getDescription().replace("/n", "")); -// } -// } -// -// if (lines.size() == 0) { -// sender.sendMessage(ChatColor.RED + Jobs.getLanguage().getMessage("command.browse.error.nojobs")); -// return true; -// } -// -// if (sender instanceof Player && Jobs.getGCManager().JobsGUIOpenOnBrowse) { -// -// Inventory inv = null; -// try { -// inv = Jobs.getGUIManager().CreateJobsGUI((Player) sender); -// } catch (Exception e) { -// ((Player) sender).closeInventory(); -// Jobs.getGUIManager().GuiList.remove(((Player) sender).getName()); -// return true; -// } -// if (inv == null) -// return true; -// -// ((Player) sender).openInventory(inv); -// -// } -// -// if (Jobs.getGCManager().JobsGUIShowChatBrowse) { -// sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.header")); -// for (String line : lines) { -// sender.sendMessage(line); -// } -// sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.footer")); -// } return true; } } diff --git a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java index d9c6c4ff..51750c99 100644 --- a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java @@ -80,7 +80,8 @@ public class GeneralConfigManager { public boolean PayForRenaming, PayForEachCraft, SignsEnabled, SignsColorizeJobName, ShowToplistInScoreboard, useGlobalTimer, useCoreProtect, BlockPlaceUse, EnableAnounceMessage, useSilkTouchProtection, UseCustomNames, - UseJobsBrowse, PreventSlimeSplit, PreventMagmaCubeSplit, PreventHopperFillUps, PreventBrewingStandFillUps; + UseJobsBrowse, PreventSlimeSplit, PreventMagmaCubeSplit, PreventHopperFillUps, PreventBrewingStandFillUps, + BrowseUseNewLook; public int globalblocktimer, CowMilkingTimer, CoreProtectInterval, BlockPlaceInterval, InfoUpdateInterval; public Double TreeFellerMultiplier, gigaDrillMultiplier, superBreakerMultiplier; @@ -871,6 +872,8 @@ public class GeneralConfigManager { c.getW().addComment("JobsBrowse.ShowPenaltyBonus", "Do you want to show penalty and bonus in jobs browse window. Only works if this feature is enabled"); ShowPenaltyBonus = c.get("JobsBrowse.ShowPenaltyBonus", true); + c.getW().addComment("JobsBrowse.UseNewLook", "Defines if you want to use new /jobs browse look or old one"); + BrowseUseNewLook = c.get("JobsBrowse.UseNewLook", true); c.getW().addComment("JobsBrowse.AmountToShow", "Defines amount of jobs to be shown in one page for /jobs browse"); BrowseAmountToShow = c.get("JobsBrowse.AmountToShow", 5);