diff --git a/pom.xml b/pom.xml index 933d2a26..c474a81f 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 Jobs jobs - 5.1.0.0 + 5.1.2.0 Jobs http://maven.apache.org diff --git a/src/main/java/com/gamingmesh/jobs/Gui/GuiManager.java b/src/main/java/com/gamingmesh/jobs/Gui/GuiManager.java index 7b8ba93a..fe6d6502 100644 --- a/src/main/java/com/gamingmesh/jobs/Gui/GuiManager.java +++ b/src/main/java/com/gamingmesh/jobs/Gui/GuiManager.java @@ -162,7 +162,7 @@ public class GuiManager { guiItem.setItemMeta(meta); - gui.addButton(new CMIGuiButton(job.getGuiSlot() >= 0 ? job.getGuiSlot() : pos, guiItem) { + CMIGuiButton button = new CMIGuiButton(job.getGuiSlot() >= 0 ? job.getGuiSlot() : pos, guiItem) { @Override public void click(GUIClickType type) { @@ -202,7 +202,13 @@ public class GuiManager { break; } } - }); + }; + + if (jPlayer.isInJob(job)) { + button.setGlowing(); + } + + gui.addButton(button); i++; } 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 d61197d5..89188b3b 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/browse.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/browse.java @@ -18,253 +18,253 @@ public class browse implements Cmd { @Override public boolean perform(Jobs plugin, CommandSender sender, final String[] args) { - boolean senderIsPlayer = sender instanceof Player; + boolean senderIsPlayer = sender instanceof Player; - if (Jobs.getGCManager().BrowseUseNewLook) { - if (Jobs.getJobs().isEmpty()) { - sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.error.nojobs")); - return true; - } + if (Jobs.getGCManager().BrowseUseNewLook) { + if (Jobs.getJobs().isEmpty()) { + sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.error.nojobs")); + return true; + } - List jobList = new ArrayList<>(Jobs.getJobs()); - if (senderIsPlayer && Jobs.getGCManager().JobsGUIOpenOnBrowse) { - try { - plugin.getGUIManager().openJobsBrowseGUI((Player) sender); - } catch (Throwable e) { - ((Player) sender).closeInventory(); - } + List jobList = new ArrayList<>(Jobs.getJobs()); + if (senderIsPlayer && Jobs.getGCManager().JobsGUIOpenOnBrowse) { + try { + plugin.getGUIManager().openJobsBrowseGUI((Player) sender); + } catch (Throwable e) { + ((Player) sender).closeInventory(); + } - return true; - } + return true; + } - int page = 1; - if (senderIsPlayer) { - for (String one : args) { - if (one.startsWith("-p:")) { - try { - page = Integer.parseInt(one.substring("-p:".length())); - } catch (Exception e) { - } - } - } - } + int page = 1; + if (senderIsPlayer) { + for (String one : args) { + if (one.startsWith("-p:")) { + try { + page = Integer.parseInt(one.substring("-p:".length())); + } catch (Exception e) { + } + } + } + } - Job j = null; - for (String one : args) { - if (one.startsWith("-j:")) { - j = Jobs.getJob(one.substring("-j:".length())); - continue; - } - } + Job j = null; + for (String one : args) { + if (one.startsWith("-j:")) { + j = Jobs.getJob(one.substring("-j:".length())); + continue; + } + } - if (senderIsPlayer) { - 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 (senderIsPlayer) { + 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 += Jobs.getLanguage().getMessage("command.browse.output.description", "[description]", one.getDescription().replaceAll("/n|\n", "")); - else { - for (String desc : one.getFullDescription()) { - hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.description", "[description]", desc); - } - } + if (!one.getDescription().isEmpty()) + hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.description", "[description]", one.getDescription().replaceAll("/n|\n", "")); + else { + for (String desc : one.getFullDescription()) { + hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.description", "[description]", desc); + } + } - int maxLevel = one.getMaxLevel(sender); - if (maxLevel > 0) { - if (!hoverMsg.isEmpty()) - hoverMsg += " \n"; - hoverMsg += Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", maxLevel); - } + int maxLevel = one.getMaxLevel(sender); + if (maxLevel > 0) { + if (!hoverMsg.isEmpty()) + hoverMsg += " \n"; + hoverMsg += Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", maxLevel); + } - if (Jobs.getGCManager().ShowTotalWorkers) { - if (!hoverMsg.isEmpty()) - hoverMsg += " \n"; - hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", one.getTotalPlayers()); + 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 (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) { + if (!hoverMsg.isEmpty()) + hoverMsg += " \n"; - int bonus = (int) (one.getBonus() * 100); - if (bonus < 0) - hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", bonus * -1); - else - hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", bonus); - } + int bonus = (int) (one.getBonus() * 100); + if (bonus < 0) + hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", bonus * -1); + else + hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", bonus); + } - if (!hoverMsg.isEmpty()) - hoverMsg += " \n"; - hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.click"); + if (!hoverMsg.isEmpty()) + hoverMsg += " \n"; + hoverMsg += Jobs.getLanguage().getMessage("command.browse.output.click"); - rm.addText(Jobs.getLanguage().getMessage("command.browse.output.list", "[place]", pi.getPositionForOutput(), - "[jobname]", one.getName())).addHover(hoverMsg).addCommand("jobs browse -j:" + one.getName()); + rm.addText(Jobs.getLanguage().getMessage("command.browse.output.list", "[place]", pi.getPositionForOutput(), + "[jobname]", one.getName())).addHover(hoverMsg).addCommand("jobs browse -j:" + one.getName()); - rm.show(sender); - } - plugin.showPagination(sender, pi, "jobs browse", "-p:"); - } else { + rm.show(sender); + } + plugin.showPagination(sender, pi, "jobs browse", "-p:"); + } 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())); - int maxLevel = j.getMaxLevel(sender); - if (maxLevel > 0) - sender.sendMessage(Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", maxLevel)); + int maxLevel = j.getMaxLevel(sender); + if (maxLevel > 0) + sender.sendMessage(Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", maxLevel)); - if (Jobs.getGCManager().ShowTotalWorkers) - sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", j.getTotalPlayers())); + if (Jobs.getGCManager().ShowTotalWorkers) + sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", j.getTotalPlayers())); - if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) { - int bonus = (int) (j.getBonus() * 100); - if (bonus < 0) - sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", bonus * -1)); - else - sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", bonus)); - } + if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) { + int bonus = (int) (j.getBonus() * 100); + if (bonus < 0) + sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", bonus * -1)); + else + sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", bonus)); + } - for (String one : j.getFullDescription()) { - sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.description", "[description]", one)); - } + for (String one : j.getFullDescription()) { + sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.description", "[description]", one)); + } - RawMessage rm = new RawMessage(); - rm.addText(Jobs.getLanguage().getMessage("command.browse.output.detailed")) - .addHover(Jobs.getLanguage().getMessage("command.browse.output.detailed")).addCommand("jobs info " + j.getName()); - rm.show(sender); - rm.clear(); - rm.addText(Jobs.getLanguage().getMessage("command.browse.output.chooseJob")) - .addHover(Jobs.getLanguage().getMessage("command.browse.output.chooseJobHover")) - .addCommand("jobs join " + j.getName() + " -needConfirmation").show(sender); - } - } else { - if (j == null) { - sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.console.newHeader", "[amount]", jobList.size(), "\\n", "\n")); - for (Job one : jobList) { - String msg = ""; + RawMessage rm = new RawMessage(); + rm.addText(Jobs.getLanguage().getMessage("command.browse.output.detailed")) + .addHover(Jobs.getLanguage().getMessage("command.browse.output.detailed")).addCommand("jobs info " + j.getName()); + rm.show(sender); + rm.clear(); + rm.addText(Jobs.getLanguage().getMessage("command.browse.output.chooseJob")) + .addHover(Jobs.getLanguage().getMessage("command.browse.output.chooseJobHover")) + .addCommand("jobs join " + j.getName() + " -needConfirmation").show(sender); + } + } else { + if (j == null) { + sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.console.newHeader", "[amount]", jobList.size(), "\\n", "\n")); + for (Job one : jobList) { + String msg = ""; - if (!one.getDescription().isEmpty()) - msg += Jobs.getLanguage().getMessage("command.browse.output.console.description", "[description]", one.getDescription().replaceAll("/n|\n", "")); - else { - for (String desc : one.getFullDescription()) { - msg += Jobs.getLanguage().getMessage("command.browse.output.console.description", "[description]", desc); - } - } + if (!one.getDescription().isEmpty()) + msg += Jobs.getLanguage().getMessage("command.browse.output.console.description", "[description]", one.getDescription().replaceAll("/n|\n", "")); + else { + for (String desc : one.getFullDescription()) { + msg += Jobs.getLanguage().getMessage("command.browse.output.console.description", "[description]", desc); + } + } - int maxLevel = one.getMaxLevel(sender); - if (maxLevel > 0) - msg += Jobs.getLanguage().getMessage("command.browse.output.console.newMax", "[max]", maxLevel); + int maxLevel = one.getMaxLevel(sender); + if (maxLevel > 0) + msg += Jobs.getLanguage().getMessage("command.browse.output.console.newMax", "[max]", maxLevel); - if (Jobs.getGCManager().ShowTotalWorkers) - msg += Jobs.getLanguage().getMessage("command.browse.output.console.totalWorkers", "[amount]", one.getTotalPlayers()); + if (Jobs.getGCManager().ShowTotalWorkers) + msg += Jobs.getLanguage().getMessage("command.browse.output.console.totalWorkers", "[amount]", one.getTotalPlayers()); - if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) { - int bonus = (int) (one.getBonus() * 100); - if (bonus < 0) - msg += Jobs.getLanguage().getMessage("command.browse.output.console.penalty", "[amount]", bonus * -1); - else - msg += Jobs.getLanguage().getMessage("command.browse.output.console.bonus", "[amount]", bonus); - } + if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) { + int bonus = (int) (one.getBonus() * 100); + if (bonus < 0) + msg += Jobs.getLanguage().getMessage("command.browse.output.console.penalty", "[amount]", bonus * -1); + else + msg += Jobs.getLanguage().getMessage("command.browse.output.console.bonus", "[amount]", bonus); + } - msg += Jobs.getLanguage().getMessage("command.browse.output.console.list", "[jobname]", one.getName()); + msg += Jobs.getLanguage().getMessage("command.browse.output.console.list", "[jobname]", one.getName()); - sender.sendMessage(msg); - } - } else { - sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.jobHeader", "[jobname]", j.getName())); + sender.sendMessage(msg); + } + } else { + sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.jobHeader", "[jobname]", j.getName())); - int maxLevel = j.getMaxLevel(sender); - if (maxLevel > 0) - sender.sendMessage(Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", maxLevel)); + int maxLevel = j.getMaxLevel(sender); + if (maxLevel > 0) + sender.sendMessage(Jobs.getLanguage().getMessage("command.info.help.newMax", "[max]", maxLevel)); - if (Jobs.getGCManager().ShowTotalWorkers) - sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", j.getTotalPlayers())); + if (Jobs.getGCManager().ShowTotalWorkers) + sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", j.getTotalPlayers())); - if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) { - int bonus = (int) (j.getBonus() * 100); - if (bonus < 0) - sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", bonus * -1)); - else - sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", bonus)); - } + if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) { + int bonus = (int) (j.getBonus() * 100); + if (bonus < 0) + sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", bonus * -1)); + else + sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", bonus)); + } - for (String one : j.getFullDescription()) { - sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.description", "[description]", one)); - } - } - } - } else { - List lines = new ArrayList<>(); - for (Job job : Jobs.getJobs()) { - if (Jobs.getGCManager().getHideJobsWithoutPermission()) { - if (!Jobs.getCommandManager().hasJobPermission(sender, job)) - continue; - } + for (String one : j.getFullDescription()) { + sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.description", "[description]", one)); + } + } + } + } else { + List 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()); + StringBuilder builder = new StringBuilder(); + builder.append(" "); + builder.append(job.getChatColor().toString()); + builder.append(job.getName()); - int maxLevel = job.getMaxLevel(sender); - if (maxLevel > 0) { - builder.append(CMIChatColor.WHITE.toString()); - builder.append(Jobs.getLanguage().getMessage("command.info.help.max")); - builder.append(maxLevel); - } + int maxLevel = job.getMaxLevel(sender); + if (maxLevel > 0) { + builder.append(CMIChatColor.WHITE.toString()); + builder.append(Jobs.getLanguage().getMessage("command.info.help.max")); + builder.append(maxLevel); + } - if (Jobs.getGCManager().ShowTotalWorkers) - builder.append(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", job.getTotalPlayers())); + if (Jobs.getGCManager().ShowTotalWorkers) + builder.append(Jobs.getLanguage().getMessage("command.browse.output.totalWorkers", "[amount]", job.getTotalPlayers())); - if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) { - int bonus = (int) (job.getBonus() * 100); - if (bonus < 0) - builder.append(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", bonus * -1)); - else - builder.append(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", bonus)); - } + if (Jobs.getGCManager().useDynamicPayment && Jobs.getGCManager().ShowPenaltyBonus) { + int bonus = (int) (job.getBonus() * 100); + if (bonus < 0) + builder.append(Jobs.getLanguage().getMessage("command.browse.output.penalty", "[amount]", bonus * -1)); + else + builder.append(Jobs.getLanguage().getMessage("command.browse.output.bonus", "[amount]", bonus)); + } - lines.add(builder.toString()); + lines.add(builder.toString()); - if (!job.getDescription().isEmpty()) - lines.add(" - " + job.getDescription().replaceAll("/n|\n", "")); - else { - for (String desc : job.getFullDescription()) { - lines.add(" - " + desc); - } - } - } + if (!job.getDescription().isEmpty()) + lines.add(" - " + job.getDescription().replaceAll("/n|\n", "")); + else { + for (String desc : job.getFullDescription()) { + lines.add(" - " + desc); + } + } + } - if (lines.isEmpty()) { - sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.error.nojobs")); - return true; - } + if (lines.isEmpty()) { + sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.error.nojobs")); + return true; + } - if (senderIsPlayer && Jobs.getGCManager().JobsGUIOpenOnBrowse) { - try { - plugin.getGUIManager().openJobsBrowseGUI((Player) sender); - } catch (Throwable e) { - ((Player) sender).closeInventory(); - } + if (senderIsPlayer && Jobs.getGCManager().JobsGUIOpenOnBrowse) { + try { + plugin.getGUIManager().openJobsBrowseGUI((Player) sender); + } catch (Throwable e) { + ((Player) sender).closeInventory(); + } - return true; - } + return true; + } - if (Jobs.getGCManager().JobsGUIShowChatBrowse) { - sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.header")); - lines.forEach(sender::sendMessage); - sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.footer")); - } - } - return true; + if (Jobs.getGCManager().JobsGUIShowChatBrowse) { + sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.header")); + lines.forEach(sender::sendMessage); + sender.sendMessage(Jobs.getLanguage().getMessage("command.browse.output.footer")); + } + } + return true; } } diff --git a/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java b/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java index 5eef7375..7c7a2b25 100644 --- a/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java @@ -587,7 +587,7 @@ public class LanguageManager { c.get("command.promote.output.target", "You have been promoted %levelsgained% levels in %jobname%."); c.get("command.exp.help.info", "Change the player exp for job."); - c.get("command.exp.help.args", "[playername] [jobname] set/add/take [amount]"); + c.get("command.exp.help.args", "[playername] [jobname] set/add/take [amount](rand_[min]-[max]) (-s) (-sa)"); Jobs.getGCManager().getCommandArgs().put("exp", Arrays.asList("[playername]", "[jobname]", "set%%add%%take")); c.get("command.exp.error.nojob", "&cThis player must first join a job."); c.get("command.exp.output.target", "&eYour exp was changed for %jobname% &eand now you at &6%level%lvl &eand with &6%exp%exp."); diff --git a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java index c6d2ede1..3ab54817 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java @@ -381,7 +381,7 @@ public class JobsPlayer { boostCounter.put(jobName, counterList); return boost; } - + private Double getPlayerBoostNew(String jobName, CurrencyType type) { Double v1 = Jobs.getPermissionManager().getMaxPermission(this, "jobs.boost." + jobName + "." + type.getName(), true, false); Double boost = v1; diff --git a/src/main/java/com/gamingmesh/jobs/hooks/stackMob/StackMobHandler.java b/src/main/java/com/gamingmesh/jobs/hooks/stackMob/StackMobHandler.java index 76ec9971..b00bf579 100644 --- a/src/main/java/com/gamingmesh/jobs/hooks/stackMob/StackMobHandler.java +++ b/src/main/java/com/gamingmesh/jobs/hooks/stackMob/StackMobHandler.java @@ -10,15 +10,15 @@ import uk.antiperson.stackmob.entity.StackEntity; public class StackMobHandler { - public boolean isStacked(LivingEntity entity) { - return getPlugin().getEntityManager().isStackedEntity(entity); - } + public boolean isStacked(LivingEntity entity) { + return getPlugin().getEntityManager().isStackedEntity(entity); + } - public Collection getStackEntities() { - return getPlugin().getEntityManager().getStackEntities(); - } + public Collection getStackEntities() { + return getPlugin().getEntityManager().getStackEntities(); + } - public StackMob getPlugin() { - return JavaPlugin.getPlugin(StackMob.class); - } + public StackMob getPlugin() { + return JavaPlugin.getPlugin(StackMob.class); + } }