From eb978e6db8c31dbd556bca5243481faa8b93d309 Mon Sep 17 00:00:00 2001 From: montlikadani Date: Sat, 4 Jul 2020 18:52:49 +0200 Subject: [PATCH] Fix when opening browse from jobs info --- .../com/gamingmesh/jobs/Gui/GuiManager.java | 47 +++++++++---------- .../jobs/commands/JobsCommands.java | 6 +-- .../gamingmesh/jobs/commands/list/demote.java | 2 +- .../jobs/commands/list/editjobs.java | 2 +- .../jobs/commands/list/editquests.java | 8 ++-- .../gamingmesh/jobs/commands/list/employ.java | 6 +-- .../gamingmesh/jobs/commands/list/exp.java | 2 +- .../gamingmesh/jobs/commands/list/fire.java | 4 +- .../jobs/commands/list/grantxp.java | 2 +- .../gamingmesh/jobs/commands/list/join.java | 6 +-- .../gamingmesh/jobs/commands/list/leave.java | 4 +- .../gamingmesh/jobs/commands/list/level.java | 2 +- .../jobs/commands/list/promote.java | 2 +- .../jobs/commands/list/removexp.java | 2 +- .../jobs/commands/list/transfer.java | 4 +- .../jobs/config/BossBarManager.java | 2 +- .../com/gamingmesh/jobs/container/Job.java | 4 ++ .../gamingmesh/jobs/container/JobsPlayer.java | 2 +- 18 files changed, 54 insertions(+), 53 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/Gui/GuiManager.java b/src/main/java/com/gamingmesh/jobs/Gui/GuiManager.java index 776e4781..7f74c625 100644 --- a/src/main/java/com/gamingmesh/jobs/Gui/GuiManager.java +++ b/src/main/java/com/gamingmesh/jobs/Gui/GuiManager.java @@ -126,7 +126,7 @@ public class GuiManager { ItemStack GuiItem = job.getGuiItem(); ItemMeta meta = GuiItem.getItemMeta(); - meta.setDisplayName(job.getChatColor() + job.getName()); + meta.setDisplayName(job.getNameWithColor()); meta.setLore(Lore); GuiItem.setItemMeta(meta); @@ -222,12 +222,12 @@ public class GuiManager { double xp = jInfo.getExperience(level, numjobs); xp = boost.getFinalAmount(CurrencyType.EXP, xp) + ((Jobs.getPlayerManager().getInventoryBoost(player, job) - .get(CurrencyType.EXP)) + 1); + .get(CurrencyType.EXP)) + 1); String xpColor = xp >= 0 ? "" : ChatColor.GRAY.toString(); double points = jInfo.getPoints(level, numjobs); points = boost.getFinalAmount(CurrencyType.POINTS, points) + ((Jobs.getPlayerManager().getInventoryBoost(player, job) - .get(CurrencyType.POINTS)) + 1); + .get(CurrencyType.POINTS)) + 1); String pointsColor = xp >= 0 ? "" : ChatColor.RED.toString(); if (income == 0D && points == 0D && xp == 0D) @@ -237,16 +237,16 @@ public class GuiManager { String val = ""; if (income != 0.0) - val += Jobs.getLanguage().getMessage("command.info.help.money", "%money%", incomeColor + - String.format(Jobs.getGCManager().getDecimalPlacesMoney(), income)); + val += Jobs.getLanguage().getMessage("command.info.help.money", "%money%", incomeColor + + String.format(Jobs.getGCManager().getDecimalPlacesMoney(), income)); if (points != 0.0) val += Jobs.getLanguage().getMessage("command.info.help.points", "%points%", pointsColor - + String.format(Jobs.getGCManager().getDecimalPlacesPoints(), points)); + + String.format(Jobs.getGCManager().getDecimalPlacesPoints(), points)); if (xp != 0.0) val += Jobs.getLanguage().getMessage("command.info.help.exp", "%exp%", xpColor - + String.format(Jobs.getGCManager().getDecimalPlacesExp(), xp)); + + String.format(Jobs.getGCManager().getDecimalPlacesExp(), xp)); Lore.add(Jobs.getLanguage().getMessage("command.info.help.material", "%material%", itemName) + val); @@ -261,7 +261,7 @@ public class GuiManager { } ItemMeta meta = GuiItem.getItemMeta(); - meta.setDisplayName(job.getChatColor() + job.getName()); + meta.setDisplayName(job.getNameWithColor()); meta.setLore(Lore); GuiItem.setItemMeta(meta); tempInv.setItem(i, GuiItem.clone()); @@ -281,7 +281,7 @@ public class GuiManager { } ItemMeta meta = GuiItem.getItemMeta(); - meta.setDisplayName(job.getChatColor() + job.getName()); + meta.setDisplayName(job.getNameWithColor()); meta.setLore(Lore); GuiItem.setItemMeta(meta); tempInv.setItem(i, GuiItem.clone()); @@ -307,24 +307,21 @@ public class GuiManager { gui.addButton(new CMIGuiButton(i1, items.get(i1))); } - if (fromCommand) { - return; + if (!fromCommand) { + ItemStack skull = Jobs.getGCManager().guiBackButton; + ItemMeta skullMeta = skull.getItemMeta(); + + skullMeta.setDisplayName(Jobs.getLanguage().getMessage("command.info.gui.back")); + skull.setItemMeta(skullMeta); + + gui.addButton(new CMIGuiButton(backButton, skull) { + @Override + public void click(GUIClickType type) { + openJobsBrowseGUI(player); + } + }); } - ItemStack skull = Jobs.getGCManager().guiBackButton; - - ItemMeta skullMeta = skull.getItemMeta(); - skullMeta.setDisplayName(Jobs.getLanguage().getMessage("command.info.gui.back")); - - skull.setItemMeta(skullMeta); - - gui.addButton(new CMIGuiButton(backButton, skull) { - @Override - public void click(GUIClickType type) { - openJobsBrowseGUI(player); - } - }); - gui.fillEmptyButtons(); gui.open(); } diff --git a/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java b/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java index b54b0715..dc07814a 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java +++ b/src/main/java/com/gamingmesh/jobs/commands/JobsCommands.java @@ -304,7 +304,7 @@ public class JobsCommands implements CommandExecutor { message.add(m); } else if (showAllTypes == 0) { String myMessage = Jobs.getLanguage().getMessage("command.info.output." + actionType.getName().toLowerCase() + ".none"); - myMessage = myMessage.replace("%jobname%", job.getChatColor() + job.getName()); + myMessage = myMessage.replace("%jobname%", job.getNameWithColor()); message.add(myMessage); } } @@ -418,7 +418,7 @@ public class JobsCommands implements CommandExecutor { Title title = Jobs.gettitleManager().getTitle(jobProg.getLevel(), jobProg.getJob().getName()); String message = Jobs.getLanguage().getMessage("command.stats.output", "%joblevel%", jobProg.getLevel(), - "%jobname%", jobProg.getJob().getChatColor() + jobProg.getJob().getName(), + "%jobname%", jobProg.getJob().getNameWithColor(), "%jobxp%", Math.round(jobProg.getExperience() * 100.0) / 100.0, "%jobmaxxp%", jobProg.getMaxExperience(), "%titlename%", title == null ? "Unknown" : title.getName()); @@ -457,7 +457,7 @@ public class JobsCommands implements CommandExecutor { double exp = jPlayer.getExpAfterRejoin(jobProg, jPlayer.getLevelAfterRejoin(jobProg)); String message = Jobs.getLanguage().getMessage("command.stats.output", "%joblevel%", level, - "%jobname%", jobProg.getJob().getChatColor() + jobProg.getJob().getName(), + "%jobname%", jobProg.getJob().getNameWithColor(), "%jobxp%", Math.round(exp * 100.0) / 100.0, "%jobmaxxp%", jobProg.getMaxExperience(level)); return " " + jobProgressMessage(jobProg.getMaxExperience(level), exp) + " " + message; diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/demote.java b/src/main/java/com/gamingmesh/jobs/commands/list/demote.java index 6a89b6a0..c3853d64 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/demote.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/demote.java @@ -42,7 +42,7 @@ public class demote implements Cmd { Player player = Bukkit.getServer().getPlayer(jPlayer.getUniqueId()); if (player != null) { String message = Jobs.getLanguage().getMessage("command.demote.output.target", - "%jobname%", job.getChatColor() + job.getName() + ChatColor.WHITE, + "%jobname%", job.getNameWithColor() + ChatColor.WHITE, "%levelslost%", levelsLost); player.sendMessage(message); } diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/editjobs.java b/src/main/java/com/gamingmesh/jobs/commands/list/editjobs.java index a9b3151a..ef886018 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/editjobs.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/editjobs.java @@ -45,7 +45,7 @@ public class editjobs implements Cmd { showPath(player, null, null, null); for (Job one : Jobs.getJobs()) { RawMessage rm = new RawMessage(); - rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.jobs", "%jobname%", one.getChatColor() + one.getName()), one.getName(), "jobs editjobs list " + one.getName()); + rm.add(Jobs.getLanguage().getMessage("command.editjobs.help.list.jobs", "%jobname%", one.getNameWithColor()), one.getName(), "jobs editjobs list " + one.getName()); rm.show(sender); } Util.getJobsEditorMap().remove(player.getUniqueId()); diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/editquests.java b/src/main/java/com/gamingmesh/jobs/commands/list/editquests.java index 0b47c83f..8a0a1af6 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/editquests.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/editquests.java @@ -49,8 +49,8 @@ public class editquests implements Cmd { for (Job one : Jobs.getJobs()) { RawMessage rm = new RawMessage(); - rm.add(Jobs.getLanguage().getMessage("command.editquests.help.list.jobs", "%jobname%", one.getChatColor() - + one.getName()), one.getName(), "jobs editquests list " + one.getName()); + rm.add(Jobs.getLanguage().getMessage("command.editquests.help.list.jobs", "%jobname%", one.getNameWithColor()), + one.getName(), "jobs editquests list " + one.getName()); rm.show(sender); } @@ -595,8 +595,8 @@ public class editquests implements Cmd { if (job != null) { rm = new RawMessage(); - rm.add(Jobs.getLanguage().getMessage("command.editquests.help.list.jobs", "%jobname%", job.getChatColor() - + job.getName()), job.getName(), "jobs editquests list " + job.getName()); + rm.add(Jobs.getLanguage().getMessage("command.editquests.help.list.jobs", "%jobname%", job.getNameWithColor()), + job.getName(), "jobs editquests list " + job.getName()); rm.show(player); } diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/employ.java b/src/main/java/com/gamingmesh/jobs/commands/list/employ.java index 98340a01..25484ca3 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/employ.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/employ.java @@ -33,13 +33,13 @@ public class employ implements Cmd { if (jPlayer.isInJob(job)) { // already in job message - sender.sendMessage(Jobs.getLanguage().getMessage("command.employ.error.alreadyin", "%jobname%", job.getChatColor() + job.getName())); + sender.sendMessage(Jobs.getLanguage().getMessage("command.employ.error.alreadyin", "%jobname%", job.getNameWithColor())); return true; } if (job.getMaxSlots() != null && Jobs.getUsedSlots(job) >= job.getMaxSlots()) { String message = Jobs.getLanguage().getMessage("command.employ.error.fullslots"); - message = message.replace("%jobname%", job.getChatColor() + job.getName()); + message = message.replace("%jobname%", job.getNameWithColor()); sender.sendMessage(message); return true; } @@ -49,7 +49,7 @@ public class employ implements Cmd { Jobs.getPlayerManager().joinJob(jPlayer, job); Player player = jPlayer.getPlayer(); if (player != null) - player.sendMessage(Jobs.getLanguage().getMessage("command.employ.output.target", "%jobname%", job.getChatColor() + job.getName())); + player.sendMessage(Jobs.getLanguage().getMessage("command.employ.output.target", "%jobname%", job.getNameWithColor())); sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); } catch (Throwable e) { diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/exp.java b/src/main/java/com/gamingmesh/jobs/commands/list/exp.java index 69dfc206..ab2a8e0d 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/exp.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/exp.java @@ -83,7 +83,7 @@ public class exp implements Cmd { Player player = jPlayer.getPlayer(); if (player != null) - player.sendMessage(Jobs.getLanguage().getMessage("command.exp.output.target", "%jobname%", job.getChatColor() + job.getName(), "%level%", prog.getLevel(), "%exp%", prog + player.sendMessage(Jobs.getLanguage().getMessage("command.exp.output.target", "%jobname%", job.getNameWithColor(), "%level%", prog.getLevel(), "%exp%", prog .getExperience())); sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); } else diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/fire.java b/src/main/java/com/gamingmesh/jobs/commands/list/fire.java index 38e99717..0f7e08d1 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/fire.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/fire.java @@ -33,14 +33,14 @@ public class fire implements Cmd { } if (!jPlayer.isInJob(job)) { - sender.sendMessage(Jobs.getLanguage().getMessage("command.fire.error.nojob", "%jobname%", job.getChatColor() + job.getName())); + sender.sendMessage(Jobs.getLanguage().getMessage("command.fire.error.nojob", "%jobname%", job.getNameWithColor())); return true; } try { Jobs.getPlayerManager().leaveJob(jPlayer, job); Player player = jPlayer.getPlayer(); if (player != null) - player.sendMessage(Jobs.getLanguage().getMessage("command.fire.output.target", "%jobname%", job.getChatColor() + job.getName())); + player.sendMessage(Jobs.getLanguage().getMessage("command.fire.output.target", "%jobname%", job.getNameWithColor())); sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); } catch (Throwable e) { diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/grantxp.java b/src/main/java/com/gamingmesh/jobs/commands/list/grantxp.java index 7e6db9be..3f400475 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/grantxp.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/grantxp.java @@ -50,7 +50,7 @@ public class grantxp implements Cmd { Player player = jPlayer.getPlayer(); if (player != null) { String message = Jobs.getLanguage().getMessage("command.grantxp.output.target", - "%jobname%", job.getChatColor() + job.getName(), + "%jobname%", job.getNameWithColor(), "%xpgained%", xpGained); player.sendMessage(message); } diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/join.java b/src/main/java/com/gamingmesh/jobs/commands/list/join.java index 920ace37..766b8be6 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/join.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/join.java @@ -49,12 +49,12 @@ public class join implements Cmd { JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender); if (jPlayer.isInJob(job)) { // already in job message - pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.alreadyin", "%jobname%", job.getChatColor() + job.getName())); + pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.alreadyin", "%jobname%", job.getNameWithColor())); return true; } if (job.getMaxSlots() != null && Jobs.getUsedSlots(job) >= job.getMaxSlots()) { - pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.fullslots", "%jobname%", job.getChatColor() + job.getName())); + pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.error.fullslots", "%jobname%", job.getNameWithColor())); return true; } @@ -82,7 +82,7 @@ public class join implements Cmd { } Jobs.getPlayerManager().joinJob(jPlayer, job); - pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.success", "%jobname%", job.getChatColor() + job.getName())); + pSender.sendMessage(Jobs.getLanguage().getMessage("command.join.success", "%jobname%", job.getNameWithColor())); return true; } } diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/leave.java b/src/main/java/com/gamingmesh/jobs/commands/list/leave.java index 4281920d..cbb908f6 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/leave.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/leave.java @@ -46,7 +46,7 @@ public class leave implements Cmd { 20 * Jobs.getGCManager().ConfirmExpiryTime); pSender.sendMessage(Jobs.getLanguage().getMessage("command.leave.confirmationNeed", "[jobname]", - job.getChatColor() + job.getName(), "[time]", Jobs.getGCManager().ConfirmExpiryTime)); + job.getNameWithColor(), "[time]", Jobs.getGCManager().ConfirmExpiryTime)); return true; } @@ -56,7 +56,7 @@ public class leave implements Cmd { JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(pSender); if (Jobs.getPlayerManager().leaveJob(jPlayer, job)) - pSender.sendMessage(Jobs.getLanguage().getMessage("command.leave.success", "%jobname%", job.getChatColor() + job.getName())); + pSender.sendMessage(Jobs.getLanguage().getMessage("command.leave.success", "%jobname%", job.getNameWithColor())); else pSender.sendMessage(Jobs.getLanguage().getMessage("general.error.job")); diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/level.java b/src/main/java/com/gamingmesh/jobs/commands/list/level.java index 8af40dec..1fe5421b 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/level.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/level.java @@ -95,7 +95,7 @@ public class level implements Cmd { Player player = jPlayer.getPlayer(); if (player != null) - player.sendMessage(Jobs.getLanguage().getMessage("command.level.output.target", "%jobname%", job.getChatColor() + job.getName(), "%level%", prog.getLevel(), "%exp%", prog.getExperience())); + player.sendMessage(Jobs.getLanguage().getMessage("command.level.output.target", "%jobname%", job.getNameWithColor(), "%level%", prog.getLevel(), "%exp%", prog.getExperience())); sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); } else diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/promote.java b/src/main/java/com/gamingmesh/jobs/commands/list/promote.java index 06048d11..4a4907eb 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/promote.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/promote.java @@ -39,7 +39,7 @@ public class promote implements Cmd { Player player = jPlayer.getPlayer(); if (player != null) player.sendMessage(Jobs.getLanguage().getMessage("command.promote.output.target", - "%jobname%", job.getChatColor() + job.getName(), + "%jobname%", job.getNameWithColor(), "%levelsgained%", levelsGained)); sender.sendMessage(Jobs.getLanguage().getMessage("general.admin.success")); diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/removexp.java b/src/main/java/com/gamingmesh/jobs/commands/list/removexp.java index be382c3a..1be3e013 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/removexp.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/removexp.java @@ -50,7 +50,7 @@ public class removexp implements Cmd { Player player = jPlayer.getPlayer(); if (player != null) { player.sendMessage(Jobs.getLanguage().getMessage("command.removexp.output.target", - "%jobname%", job.getChatColor() + job.getName(), + "%jobname%", job.getNameWithColor(), "%xplost%", xpLost)); } diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/transfer.java b/src/main/java/com/gamingmesh/jobs/commands/list/transfer.java index 186d50d5..3223187b 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/transfer.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/transfer.java @@ -44,8 +44,8 @@ public class transfer implements Cmd { Player player = jPlayer.getPlayer(); if (player != null) { String message = Jobs.getLanguage().getMessage("command.transfer.output.target", - "%oldjobname%", oldjob.getChatColor() + oldjob.getName(), - "%newjobname%", newjob.getChatColor() + newjob.getName()); + "%oldjobname%", oldjob.getNameWithColor(), + "%newjobname%", newjob.getNameWithColor()); player.sendMessage(message); } diff --git a/src/main/java/com/gamingmesh/jobs/config/BossBarManager.java b/src/main/java/com/gamingmesh/jobs/config/BossBarManager.java index 26c20797..f669e917 100644 --- a/src/main/java/com/gamingmesh/jobs/config/BossBarManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/BossBarManager.java @@ -72,7 +72,7 @@ public class BossBarManager { String message = Jobs.getLanguage().getMessage("command.stats.bossBarOutput", "%joblevel%", Integer.valueOf(jobProg.getLevel()).toString(), - "%jobname%", jobProg.getJob().getChatColor() + jobProg.getJob().getName(), + "%jobname%", jobProg.getJob().getNameWithColor(), "%jobxp%", formatter.format(Math.round(jobProg.getExperience() * 100.0) / 100.0), "%jobmaxxp%", jobProg.getMaxExperience(), "%gain%", gain); diff --git a/src/main/java/com/gamingmesh/jobs/container/Job.java b/src/main/java/com/gamingmesh/jobs/container/Job.java index 1d8ec007..fc0278a1 100644 --- a/src/main/java/com/gamingmesh/jobs/container/Job.java +++ b/src/main/java/com/gamingmesh/jobs/container/Job.java @@ -258,6 +258,10 @@ public class Job { return fullName; } + public String getNameWithColor() { + return jobColour + fullName; + } + /** * Get the job name from the config * @return the job name from the config diff --git a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java index 64caa8c7..23253f01 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobsPlayer.java @@ -685,7 +685,7 @@ public class JobsPlayer { if (gotTitle) { builder.append(" "); } - String honorificpart = prog.getJob().getChatColor() + prog.getJob().getName() + ChatColor.WHITE; + String honorificpart = prog.getJob().getNameWithColor() + ChatColor.WHITE; if (honorificpart.contains("{level}")) honorificpart = honorificpart.replace("{level}", String.valueOf(prog.getLevel())); builder.append(honorificpart);