mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-25 20:16:13 +01:00
Merge pull request #1374 from MisterFrans/dev-asyncbossbar
Added option to switch bossbar creation and management to async
This commit is contained in:
commit
faa72b80ac
@ -34,7 +34,19 @@ public class BossBarManager {
|
||||
player.getUpdateBossBarFor().clear();
|
||||
}
|
||||
|
||||
public void ShowJobProgression(final JobsPlayer player, final JobProgression jobProg, double expGain) {
|
||||
public void ShowJobProgression(final JobsPlayer player, final JobProgression jobProg, double expGain)
|
||||
{
|
||||
if(Jobs.getGCManager().isBossBarAsync())
|
||||
{
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Jobs.getInstance(), () -> ShowJobProgressionInTask(player, jobProg, expGain));
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowJobProgressionInTask(player, jobProg, expGain);
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void ShowJobProgressionInTask(final JobsPlayer player, final JobProgression jobProg, double expGain) {
|
||||
if (Version.getCurrent().isLower(Version.v1_9_R1) || !Jobs.getGCManager().BossBarsMessageByDefault)
|
||||
return;
|
||||
|
||||
|
@ -102,7 +102,7 @@ public class GeneralConfigManager {
|
||||
BossBarEnabled = false, BossBarShowOnEachAction = false, BossBarsMessageByDefault = false, ExploreCompact, DBCleaningJobsUse, DBCleaningUsersUse,
|
||||
DisabledWorldsUse, UseAsWhiteListWorldList, PaymentMethodsMoney, PaymentMethodsPoints, PaymentMethodsExp, MythicMobsEnabled,
|
||||
LoggingUse, payForCombiningItems, BlastFurnacesReassign = false, SmokerReassign = false, payForStackedEntities, payForAbove = false,
|
||||
payForEachVTradeItem, allowEnchantingBoostedItems;
|
||||
payForEachVTradeItem, allowEnchantingBoostedItems, bossBarAsync = false;
|
||||
|
||||
public ItemStack guiBackButton, guiNextButton;
|
||||
public CMIMaterial guiFiller;
|
||||
@ -890,6 +890,8 @@ public class GeneralConfigManager {
|
||||
c.addComment("BossBar.Timer", "How long in sec to show BossBar for player",
|
||||
"If you have disabled ShowOnEachAction, then keep this number higher than payment interval for better experience");
|
||||
BossBarTimer = c.get("BossBar.Timer", economyBatchDelay + 1);
|
||||
c.addComment("BossBar.Async", "If enabled, bossbar creation and management will be asynchronous.", "This avoids TPS drops when the ShowOnEachAction option is activated.");
|
||||
bossBarAsync = c.get("BossBar.Async", false);
|
||||
}
|
||||
|
||||
c.addComment("ShowActionBars", "You can enable/disable message shown for players in action bar");
|
||||
@ -1161,4 +1163,8 @@ public class GeneralConfigManager {
|
||||
public boolean isInformDuplicates() {
|
||||
return InformDuplicates;
|
||||
}
|
||||
|
||||
public boolean isBossBarAsync() {
|
||||
return bossBarAsync;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user