1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 14:05:25 +01:00

Catch exception for boss bar feature to avoid failing payments

This commit is contained in:
Zrips 2016-06-27 14:25:23 +03:00
parent c935900eed
commit 7feced2529
2 changed files with 24 additions and 14 deletions

View File

@ -922,11 +922,15 @@ public class Jobs {
if (amount == 0D && pointAmount == 0D && expAmount == 0D)
continue;
if (expAmount != 0D)
if (Jobs.getGCManager().BossBarEnabled && Jobs.getGCManager().BossBarShowOnEachAction) {
Jobs.getBBManager().ShowJobProgression(jPlayer, prog);
} else if (Jobs.getGCManager().BossBarEnabled && !Jobs.getGCManager().BossBarShowOnEachAction)
jPlayer.getUpdateBossBarFor().add(prog.getJob().getName());
try {
if (expAmount != 0D)
if (Jobs.getGCManager().BossBarEnabled && Jobs.getGCManager().BossBarShowOnEachAction) {
Jobs.getBBManager().ShowJobProgression(jPlayer, prog);
} else if (Jobs.getGCManager().BossBarEnabled && !Jobs.getGCManager().BossBarShowOnEachAction)
jPlayer.getUpdateBossBarFor().add(prog.getJob().getName());
} catch (Exception e) {
Bukkit.getConsoleSender().sendMessage("[Jobs] Some issues with boss bar feature accured, try disabling it to avoid it.");
}
// JobsPayment event
JobsExpGainEvent JobsExpGainEvent = new JobsExpGainEvent(jPlayer.getPlayer(), prog.getJob(), expAmount);

View File

@ -108,16 +108,22 @@ public class BossBarManager {
bar.setTitle(message);
double percentage = jobProg.getExperience() / jobProg.getMaxExperience();
bar.setProgress(percentage);
if (OldOne == null) {
Player target = Bukkit.getPlayer(player.getPlayer().getUniqueId());
if (target == null)
return;
bar.addPlayer(target);
OldOne = new BossBarInfo(player.getUserName(), jobProg.getJob().getName(), bar);
player.getBossBarInfo().add(OldOne);
try {
bar.setProgress(percentage);
if (OldOne == null) {
Player target = Bukkit.getPlayer(player.getPlayer().getUniqueId());
if (target == null)
return;
bar.addPlayer(target);
OldOne = new BossBarInfo(player.getUserName(), jobProg.getJob().getName(), bar);
player.getBossBarInfo().add(OldOne);
}
bar.setVisible(true);
} catch (NoSuchMethodError e) {
}
bar.setVisible(true);
if (OldOne == null)
return;
OldOne.setId(Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override