1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-26 04:25:15 +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) if (amount == 0D && pointAmount == 0D && expAmount == 0D)
continue; continue;
if (expAmount != 0D) try {
if (Jobs.getGCManager().BossBarEnabled && Jobs.getGCManager().BossBarShowOnEachAction) { if (expAmount != 0D)
Jobs.getBBManager().ShowJobProgression(jPlayer, prog); if (Jobs.getGCManager().BossBarEnabled && Jobs.getGCManager().BossBarShowOnEachAction) {
} else if (Jobs.getGCManager().BossBarEnabled && !Jobs.getGCManager().BossBarShowOnEachAction) Jobs.getBBManager().ShowJobProgression(jPlayer, prog);
jPlayer.getUpdateBossBarFor().add(prog.getJob().getName()); } 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 // JobsPayment event
JobsExpGainEvent JobsExpGainEvent = new JobsExpGainEvent(jPlayer.getPlayer(), prog.getJob(), expAmount); JobsExpGainEvent JobsExpGainEvent = new JobsExpGainEvent(jPlayer.getPlayer(), prog.getJob(), expAmount);

View File

@ -108,17 +108,23 @@ public class BossBarManager {
bar.setTitle(message); bar.setTitle(message);
double percentage = jobProg.getExperience() / jobProg.getMaxExperience(); double percentage = jobProg.getExperience() / jobProg.getMaxExperience();
bar.setProgress(percentage); try {
if (OldOne == null) { bar.setProgress(percentage);
Player target = Bukkit.getPlayer(player.getPlayer().getUniqueId()); if (OldOne == null) {
if (target == null) Player target = Bukkit.getPlayer(player.getPlayer().getUniqueId());
return; if (target == null)
bar.addPlayer(target); return;
OldOne = new BossBarInfo(player.getUserName(), jobProg.getJob().getName(), bar); bar.addPlayer(target);
player.getBossBarInfo().add(OldOne); 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() { OldOne.setId(Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {