diff --git a/src/main/java/com/gamingmesh/jobs/Jobs.java b/src/main/java/com/gamingmesh/jobs/Jobs.java index 4c2e3da6..f014db38 100644 --- a/src/main/java/com/gamingmesh/jobs/Jobs.java +++ b/src/main/java/com/gamingmesh/jobs/Jobs.java @@ -1065,7 +1065,7 @@ public class Jobs extends JavaPlugin { try { if (expAmount != 0D && GconfigManager.BossBarEnabled) if (GconfigManager.BossBarShowOnEachAction) - BBManager.ShowJobProgression(jPlayer, prog); + BBManager.ShowJobProgression(jPlayer, prog, expAmount); else jPlayer.getUpdateBossBarFor().add(prog.getJob().getName()); } catch (Throwable e) { diff --git a/src/main/java/com/gamingmesh/jobs/config/BossBarManager.java b/src/main/java/com/gamingmesh/jobs/config/BossBarManager.java index 3379a448..f9c44611 100644 --- a/src/main/java/com/gamingmesh/jobs/config/BossBarManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/BossBarManager.java @@ -38,14 +38,17 @@ public class BossBarManager { for (String one : temp) { for (JobProgression oneJob : player.getJobProgression()) { - if (one.equalsIgnoreCase(oneJob.getJob().getName())) - ShowJobProgression(player, oneJob); + if (one.equalsIgnoreCase(oneJob.getJob().getName())) { + Double lastExp = oneJob.getLastExperience(); + + ShowJobProgression(player, oneJob, oneJob.getExperience() - lastExp); + } } } player.clearUpdateBossBarFor(); } - public synchronized void ShowJobProgression(final JobsPlayer player, final JobProgression jobProg) { + public synchronized void ShowJobProgression(final JobsPlayer player, final JobProgression jobProg, double expGain) { if (Jobs.getVersionCheckManager().getVersion().isLower(Version.v1_9_R1)) return; @@ -70,11 +73,22 @@ public class BossBarManager { } NumberFormat formatter = new DecimalFormat("#0.00"); - String message = Jobs.getLanguage().getMessage("command.stats.output", + String gain = ""; + if (expGain != 0) { + expGain = (int) (expGain * 100) / 100D; + if (expGain > 0) + gain = "+" + expGain; + else + gain = "" + expGain; + gain = Jobs.getLanguage().getMessage("command.stats.bossBarGain", "%gain%", gain); + } + + String message = Jobs.getLanguage().getMessage("command.stats.bossBarOutput", "%joblevel%", Integer.valueOf(jobProg.getLevel()).toString(), "%jobname%", jobProg.getJob().getChatColor() + jobProg.getJob().getName(), "%jobxp%", formatter.format(Math.round(jobProg.getExperience() * 100.0) / 100.0), - "%jobmaxxp%", jobProg.getMaxExperience()); + "%jobmaxxp%", jobProg.getMaxExperience(), + "%gain%", gain); if (bar == null) { BarColor color = getColor(jobProg.getJob()); diff --git a/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java b/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java index 361c5828..22a03e11 100644 --- a/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/LanguageManager.java @@ -291,6 +291,8 @@ public class LanguageManager { Jobs.getGCManager().getCommandArgs().put("stats", Arrays.asList("[playername]")); c.get("command.stats.error.nojob", "Please join a job first."); c.get("command.stats.output", "Level %joblevel% for %jobname%: %jobxp%/%jobmaxxp% xp"); + c.get("command.stats.bossBarOutput", "Lvl %joblevel% %jobname%: %jobxp%/%jobmaxxp% xp%gain%"); + c.get("command.stats.bossBarGain", " &7(&f%gain%&7)"); c.get("command.shop.help.info", "Opens special jobs shop."); c.get("command.shop.help.args", ""); diff --git a/src/main/java/com/gamingmesh/jobs/container/JobProgression.java b/src/main/java/com/gamingmesh/jobs/container/JobProgression.java index 7971c843..51cfe3c4 100644 --- a/src/main/java/com/gamingmesh/jobs/container/JobProgression.java +++ b/src/main/java/com/gamingmesh/jobs/container/JobProgression.java @@ -26,6 +26,7 @@ public class JobProgression { private Job job; private JobsPlayer jPlayer; private double experience; + private Double lastExperience; private int level; private transient int maxExperience = -1; private Long leftOn = null; @@ -166,7 +167,6 @@ public class JobProgression { * @returns if level up was performed */ private boolean checkLevelUp() { - if (level == 1 && experience < 0) experience = 0; if (experience < 0) @@ -189,6 +189,9 @@ public class JobProgression { if (experience > maxExperience) experience = maxExperience; + if (lastExperience == null) + lastExperience = experience; + return ret; } @@ -208,6 +211,8 @@ public class JobProgression { ret = true; reloadMaxExperience(); } + if (lastExperience == null) + lastExperience = experience; return ret; } @@ -248,4 +253,12 @@ public class JobProgression { return msg; } + public Double getLastExperience() { + return lastExperience == null ? experience : lastExperience; + } + + public void setLastExperience(Double lastExperience) { + this.lastExperience = lastExperience; + } + } diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index fad6e900..8c10f461 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -1453,10 +1453,10 @@ public class JobsPaymentListener implements Listener { return; // pay - JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(player); - if (jDamager == null) + JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player); + if (jPlayer == null) return; - Jobs.action(jDamager, new EntityActionInfo(animal, ActionType.BREED)); + Jobs.action(jPlayer, new EntityActionInfo(animal, ActionType.BREED)); } }