1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-29 04:18:07 +01:00

Merge pull request #1704 from MisterFrans/dev-asyncboosbar-optimisation

Prevents creation of unnecessary threads when bossbar is in async
This commit is contained in:
Zrips 2024-01-25 12:56:56 +02:00 committed by GitHub
commit 79fbf40ac6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -36,6 +36,12 @@ public class BossBarManager {
}
public void ShowJobProgression(final JobsPlayer player, final JobProgression jobProg, double expGain) {
if (Version.getCurrent().isLower(Version.v1_9_R1) || !Jobs.getGCManager().BossBarsMessageByDefault)
return;
if (!ToggleBarHandling.getBossBarToggle().getOrDefault(player.getUniqueId().toString(), true))
return;
if (Jobs.getGCManager().isBossBarAsync()) {
CMIScheduler.get().runTaskAsynchronously(() -> ShowJobProgressionInTask(player, jobProg, expGain));
} else {
@ -44,12 +50,6 @@ public class BossBarManager {
}
private synchronized void ShowJobProgressionInTask(final JobsPlayer player, final JobProgression jobProg, double expGain) {
if (Version.getCurrent().isLower(Version.v1_9_R1) || !Jobs.getGCManager().BossBarsMessageByDefault)
return;
if (!ToggleBarHandling.getBossBarToggle().getOrDefault(player.getUniqueId().toString(), true))
return;
BossBar bar = null;
BossBarInfo oldOne = null;
for (BossBarInfo one : player.getBossBarInfo()) {