mirror of
https://github.com/Zrips/Jobs.git
synced 2025-01-21 15:41:19 +01:00
Lets show more informative bossbar
This commit is contained in:
parent
a40698f543
commit
fb5fad2a6c
@ -1065,7 +1065,7 @@ public class Jobs extends JavaPlugin {
|
|||||||
try {
|
try {
|
||||||
if (expAmount != 0D && GconfigManager.BossBarEnabled)
|
if (expAmount != 0D && GconfigManager.BossBarEnabled)
|
||||||
if (GconfigManager.BossBarShowOnEachAction)
|
if (GconfigManager.BossBarShowOnEachAction)
|
||||||
BBManager.ShowJobProgression(jPlayer, prog);
|
BBManager.ShowJobProgression(jPlayer, prog, expAmount);
|
||||||
else
|
else
|
||||||
jPlayer.getUpdateBossBarFor().add(prog.getJob().getName());
|
jPlayer.getUpdateBossBarFor().add(prog.getJob().getName());
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
@ -38,14 +38,17 @@ public class BossBarManager {
|
|||||||
|
|
||||||
for (String one : temp) {
|
for (String one : temp) {
|
||||||
for (JobProgression oneJob : player.getJobProgression()) {
|
for (JobProgression oneJob : player.getJobProgression()) {
|
||||||
if (one.equalsIgnoreCase(oneJob.getJob().getName()))
|
if (one.equalsIgnoreCase(oneJob.getJob().getName())) {
|
||||||
ShowJobProgression(player, oneJob);
|
Double lastExp = oneJob.getLastExperience();
|
||||||
|
|
||||||
|
ShowJobProgression(player, oneJob, oneJob.getExperience() - lastExp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
player.clearUpdateBossBarFor();
|
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))
|
if (Jobs.getVersionCheckManager().getVersion().isLower(Version.v1_9_R1))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -70,11 +73,22 @@ public class BossBarManager {
|
|||||||
}
|
}
|
||||||
NumberFormat formatter = new DecimalFormat("#0.00");
|
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(),
|
"%joblevel%", Integer.valueOf(jobProg.getLevel()).toString(),
|
||||||
"%jobname%", jobProg.getJob().getChatColor() + jobProg.getJob().getName(),
|
"%jobname%", jobProg.getJob().getChatColor() + jobProg.getJob().getName(),
|
||||||
"%jobxp%", formatter.format(Math.round(jobProg.getExperience() * 100.0) / 100.0),
|
"%jobxp%", formatter.format(Math.round(jobProg.getExperience() * 100.0) / 100.0),
|
||||||
"%jobmaxxp%", jobProg.getMaxExperience());
|
"%jobmaxxp%", jobProg.getMaxExperience(),
|
||||||
|
"%gain%", gain);
|
||||||
|
|
||||||
if (bar == null) {
|
if (bar == null) {
|
||||||
BarColor color = getColor(jobProg.getJob());
|
BarColor color = getColor(jobProg.getJob());
|
||||||
|
@ -291,6 +291,8 @@ public class LanguageManager {
|
|||||||
Jobs.getGCManager().getCommandArgs().put("stats", Arrays.asList("[playername]"));
|
Jobs.getGCManager().getCommandArgs().put("stats", Arrays.asList("[playername]"));
|
||||||
c.get("command.stats.error.nojob", "Please join a job first.");
|
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.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.info", "Opens special jobs shop.");
|
||||||
c.get("command.shop.help.args", "");
|
c.get("command.shop.help.args", "");
|
||||||
|
@ -26,6 +26,7 @@ public class JobProgression {
|
|||||||
private Job job;
|
private Job job;
|
||||||
private JobsPlayer jPlayer;
|
private JobsPlayer jPlayer;
|
||||||
private double experience;
|
private double experience;
|
||||||
|
private Double lastExperience;
|
||||||
private int level;
|
private int level;
|
||||||
private transient int maxExperience = -1;
|
private transient int maxExperience = -1;
|
||||||
private Long leftOn = null;
|
private Long leftOn = null;
|
||||||
@ -166,7 +167,6 @@ public class JobProgression {
|
|||||||
* @returns if level up was performed
|
* @returns if level up was performed
|
||||||
*/
|
*/
|
||||||
private boolean checkLevelUp() {
|
private boolean checkLevelUp() {
|
||||||
|
|
||||||
if (level == 1 && experience < 0)
|
if (level == 1 && experience < 0)
|
||||||
experience = 0;
|
experience = 0;
|
||||||
if (experience < 0)
|
if (experience < 0)
|
||||||
@ -189,6 +189,9 @@ public class JobProgression {
|
|||||||
if (experience > maxExperience)
|
if (experience > maxExperience)
|
||||||
experience = maxExperience;
|
experience = maxExperience;
|
||||||
|
|
||||||
|
if (lastExperience == null)
|
||||||
|
lastExperience = experience;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,6 +211,8 @@ public class JobProgression {
|
|||||||
ret = true;
|
ret = true;
|
||||||
reloadMaxExperience();
|
reloadMaxExperience();
|
||||||
}
|
}
|
||||||
|
if (lastExperience == null)
|
||||||
|
lastExperience = experience;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,4 +253,12 @@ public class JobProgression {
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Double getLastExperience() {
|
||||||
|
return lastExperience == null ? experience : lastExperience;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastExperience(Double lastExperience) {
|
||||||
|
this.lastExperience = lastExperience;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1453,10 +1453,10 @@ public class JobsPaymentListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// pay
|
// pay
|
||||||
JobsPlayer jDamager = Jobs.getPlayerManager().getJobsPlayer(player);
|
JobsPlayer jPlayer = Jobs.getPlayerManager().getJobsPlayer(player);
|
||||||
if (jDamager == null)
|
if (jPlayer == null)
|
||||||
return;
|
return;
|
||||||
Jobs.action(jDamager, new EntityActionInfo(animal, ActionType.BREED));
|
Jobs.action(jPlayer, new EntityActionInfo(animal, ActionType.BREED));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user