diff --git a/src/main/java/com/gamingmesh/jobs/Gui/GuiManager.java b/src/main/java/com/gamingmesh/jobs/Gui/GuiManager.java index dd12fd82..3d36e858 100644 --- a/src/main/java/com/gamingmesh/jobs/Gui/GuiManager.java +++ b/src/main/java/com/gamingmesh/jobs/Gui/GuiManager.java @@ -39,19 +39,25 @@ public class GuiManager { GuiInfoList info = GuiList.get(player.getName()); List JobsList = info.getJobList(); int i = 0; - int pos = 7; - main: for (int z = 1; z < 5; z++) { - pos += 2; - for (int x = 1; x < 8; x++) { - pos++; - if (i >= JobsList.size()) - break main; + int pos = Jobs.getGCManager().getJobsGUIStartPosition() - 1; + int group = 0; + main: for (int z = 0; z < JobsList.size(); z++) { + group++; - if (pos == slot) - return JobsList.get(i); - i++; + if (group > Jobs.getGCManager().getJobsGUIGroupAmount()) { + group = 1; + pos += Jobs.getGCManager().getJobsGUISkipAmount(); } + + pos++; + if (i >= JobsList.size()) + break main; + + if (pos == slot) + return JobsList.get(i); + i++; } + return null; } @@ -75,7 +81,7 @@ public class GuiManager { GuiList.put(player.getName(), guiInfo); - int GuiSize = 54; + int GuiSize = Jobs.getGCManager().getJobsGUIRows() * 9; JobsPlayer JPlayer = Jobs.getPlayerManager().getJobsPlayer(player); @@ -88,66 +94,74 @@ public class GuiManager { Inventory GuiInv = Bukkit.createInventory(null, GuiSize, title); int i = 0; - int pos = 7; - main: for (int z = 1; z < 5; z++) { - pos += 2; - for (int x = 1; x < 8; x++) { - pos++; - if (i >= JobsList.size()) - break main; - Job job = JobsList.get(i); + int pos = Jobs.getGCManager().getJobsGUIStartPosition() - 1; + int group = 0; + main: for (int z = 0; z < JobsList.size(); z++) { + group++; - ArrayList Lore = new ArrayList(); - - for (JobProgression onePJob : pJobs) { - if (onePJob.getJob().getName().equalsIgnoreCase(job.getName())) - Lore.add(Jobs.getLanguage().getMessage("command.info.gui.working")); - } - - int maxlevel = job.getMaxLevel(JPlayer); - if (maxlevel > 0) - Lore.add(Jobs.getLanguage().getMessage("command.info.gui.max") + maxlevel); - - if (Jobs.getGCManager().ShowTotalWorkers) - Lore.add(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", job.getTotalPlayers())); - - if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) - if (job.getBonus() < 0) - Lore.add(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", (int) (job.getBonus() * 100) * -1)); - else - Lore.add(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (job.getBonus() * 100))); - - Lore.addAll(Arrays.asList(job.getDescription().split("/n"))); - - if (job.getMaxSlots() != null) - Lore.add(Jobs.getLanguage().getMessage("command.info.gui.leftSlots") + ((job.getMaxSlots() - Jobs.getUsedSlots(job)) > 0 ? (job.getMaxSlots() - Jobs - .getUsedSlots( - job)) : 0)); - - Lore.add(Jobs.getLanguage().getMessage("command.info.gui.actions")); - for (ActionType actionType : ActionType.values()) { - List info = job.getJobInfo(actionType); - if (info != null && !info.isEmpty()) { - Lore.add(ChatColor.translateAlternateColorCodes('&', "&e" + Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase() - + ".info"))); - } - } - - Lore.add(""); - Lore.add(Jobs.getLanguage().getMessage("command.info.gui.leftClick")); - Lore.add(Jobs.getLanguage().getMessage("command.info.gui.rightClick")); - - ItemStack GuiItem = job.getGuiItem(); - - ItemMeta meta = GuiItem.getItemMeta(); - meta.setDisplayName(job.getChatColor() + job.getName()); - meta.setLore(Lore); - GuiItem.setItemMeta(meta); - - GuiInv.setItem(pos, GuiItem); - i++; + if (group > Jobs.getGCManager().getJobsGUIGroupAmount()) { + group = 1; + pos += Jobs.getGCManager().getJobsGUISkipAmount(); } +// pos += 2; +// for (int x = 1; x <= 7; x++) { + pos++; + if (i >= JobsList.size()) + break main; + Job job = JobsList.get(i); + + ArrayList Lore = new ArrayList(); + + for (JobProgression onePJob : pJobs) { + if (onePJob.getJob().getName().equalsIgnoreCase(job.getName())) + Lore.add(Jobs.getLanguage().getMessage("command.info.gui.working")); + } + + int maxlevel = job.getMaxLevel(JPlayer); + if (maxlevel > 0) + Lore.add(Jobs.getLanguage().getMessage("command.info.gui.max") + maxlevel); + + if (Jobs.getGCManager().ShowTotalWorkers) + Lore.add(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", job.getTotalPlayers())); + + if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) + if (job.getBonus() < 0) + Lore.add(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", (int) (job.getBonus() * 100) * -1)); + else + Lore.add(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", (int) (job.getBonus() * 100))); + + Lore.addAll(Arrays.asList(job.getDescription().split("/n"))); + + if (job.getMaxSlots() != null) + Lore.add(Jobs.getLanguage().getMessage("command.info.gui.leftSlots") + ((job.getMaxSlots() - Jobs.getUsedSlots(job)) > 0 ? (job.getMaxSlots() - Jobs + .getUsedSlots( + job)) : 0)); + + Lore.add(Jobs.getLanguage().getMessage("command.info.gui.actions")); + for (ActionType actionType : ActionType.values()) { + List info = job.getJobInfo(actionType); + if (info != null && !info.isEmpty()) { + Lore.add(ChatColor.translateAlternateColorCodes('&', "&e" + Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase() + + ".info"))); + } + } + + Lore.add(""); + Lore.add(Jobs.getLanguage().getMessage("command.info.gui.leftClick")); + Lore.add(Jobs.getLanguage().getMessage("command.info.gui.rightClick")); + + ItemStack GuiItem = job.getGuiItem(); + + ItemMeta meta = GuiItem.getItemMeta(); + meta.setDisplayName(job.getChatColor() + job.getName()); + meta.setLore(Lore); + GuiItem.setItemMeta(meta); + + GuiInv.setItem(pos, GuiItem); + i++; +// } + } ItemStack filler = Jobs.getGCManager().guiFiller; @@ -257,8 +271,8 @@ public class GuiManager { items.add(one); } - int GuiSize = 54; - int backButton = 45; + int GuiSize = Jobs.getGCManager().getJobsGUIRows() * 9; + int backButton = Jobs.getGCManager().getJobsGUIBackButton(); String title = Jobs.getLanguage().getMessage("command.info.gui.jobinfo", "[jobname]", job.getName()); if (title.length() > 32) diff --git a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java index a6e63690..1ba20534 100644 --- a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java @@ -103,6 +103,11 @@ public class GeneralConfigManager { EmptyServerAcountActionBar, ActionBarsMessageByDefault, ShowTotalWorkers, ShowPenaltyBonus, useDynamicPayment, useGlobalBoostScheduler, JobsGUIOpenOnBrowse, JobsGUIShowChatBrowse, JobsGUISwitcheButtons, JobsGUIOpenOnJoin; + private int JobsGUIRows, JobsGUIBackButton, + JobsGUIStartPosition, + JobsGUIGroupAmount, + JobsGUISkipAmount; + private String DecimalPlacesMoney, DecimalPlacesExp, DecimalPlacesPoints; public ItemStack guiBackButton; @@ -892,7 +897,16 @@ public class GeneralConfigManager { c.getW().addComment("JobsGUI.SwitcheButtons", "With true left mouse button will join job and right will show more info", "With false left mouse button will show more info, rigth will join job", "Dont forget to adjust locale file"); JobsGUISwitcheButtons = c.get("JobsGUI.SwitcheButtons", false); - c.getW().addComment("JobsBrowse.ShowPenaltyBonus", "Do you want to show GUI when performing /jobs join command"); + c.getW().addComment("JobsGUI.Rows", "Defines size in rows of GUI"); + JobsGUIRows = c.get("JobsGUI.Rows", 5); + c.getW().addComment("JobsGUI.BackButtonSlot", "Defines back button slot in GUI"); + JobsGUIBackButton = c.get("JobsGUI.BackButtonSlot", 37); + c.getW().addComment("JobsGUI.StartPosition", "Defines start position in gui from which job icons will be shown"); + JobsGUIStartPosition = c.get("JobsGUI.StartPosition", 11); + c.getW().addComment("JobsGUI.GroupAmount", "Defines By how many jobs we need to group up"); + JobsGUIGroupAmount = c.get("JobsGUI.GroupAmount", 7); + c.getW().addComment("JobsGUI.SkipAmount", "Defines By how many slot we need to skip after group"); + JobsGUISkipAmount = c.get("JobsGUI.SkipAmount", 2); Material tmat = Material.getMaterial(c.get("JobsGUI.BackButton.Material", "JACK_O_LANTERN")); guiBackButton = new ItemStack(tmat == null ? Material.JACK_O_LANTERN : tmat, 1, (byte) c.get("JobsGUI.BackButton.Data", 0)); @@ -965,4 +979,32 @@ public class GeneralConfigManager { return DecimalPlacesPoints; } + public int getJobsGUIRows() { + if (JobsGUIRows < 1) + JobsGUIRows = 1; + return JobsGUIRows; + } + + public int getJobsGUIBackButton() { + if (JobsGUIBackButton < 1) + JobsGUIBackButton = 1; + if (JobsGUIBackButton > JobsGUIRows * 9) + JobsGUIBackButton = JobsGUIRows * 9; + return JobsGUIBackButton - 1; + } + + public int getJobsGUIStartPosition() { + if (JobsGUIBackButton < 1) + JobsGUIBackButton = 1; + return JobsGUIStartPosition - 1; + } + + public int getJobsGUIGroupAmount() { + return JobsGUIGroupAmount; + } + + public int getJobsGUISkipAmount() { + return JobsGUISkipAmount; + } + } diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java index acc1e887..eb162765 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java @@ -232,14 +232,14 @@ public class JobsListener implements Listener { if (job != null) { Inventory inv = Jobs.getGUIManager().CreateJobsSubGUI(player, job); Inventory top = player.getOpenInventory().getTopInventory(); - if (top.getSize() == 54) + if (top.getSize() == Jobs.getGCManager().getJobsGUIRows() * 9) top.setContents(inv.getContents()); } } else if (joblist.isJobInfo()) { if (slot == joblist.getbackButton()) { Inventory inv = Jobs.getGUIManager().CreateJobsGUI(player); Inventory top = player.getOpenInventory().getTopInventory(); - if (top.getSize() == 54) + if (top.getSize() == Jobs.getGCManager().getJobsGUIRows() * 9) top.setContents(inv.getContents()); } } else if (!Jobs.getGCManager().JobsGUISwitcheButtons && event.getClick() == ClickType.RIGHT ||